EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
965 stars 183 forks source link

Show StringPicture/Picture - Possible Memory Leak #3163

Closed jetrotal closed 6 months ago

jetrotal commented 7 months ago

While doing some tests, I noticed an constant increase in memory usage on a command that simply asigned variables and created string pictures: image

Maybe the issue was caused by the repeated usage of Show string pictures, reseting the same pictures over and over again. image

I suspect the same issue can happen on the original rpg_rt and patches. To mitigate that, I suggest Avoid doing all the steps from commands like "Show Picture", "Show String Picture" and "Move Picture", If the result turns to be the exact same as it was before.

In case of move picture, maybe the command should just wait until the amount of frames it's marked to use.

Ghabry commented 7 months ago

This looks quite complex. Can you attach a testcase?

While you are at it also add one to the string split issue.

I do not have all this patch stuff (and especially TPC) setup on all devices. Is faster for me when you provide something executable.

jetrotal commented 7 months ago

testCase - show pics.zip

Ghabry commented 7 months ago

I have no idea right now why the memory is not freed. This uses the same code we use everywhere else for creating Bitmaps.

Makes me wonder now if we have an undetected memleak here in general...

Ghabry commented 7 months ago

@jetrotal the deletion fails for Picture ID 2 and ID 7.

Are you doing anything different in the Show String Picture commands of 2 and 7 compared to the rest?

jetrotal commented 7 months ago

I guess, I managed to track it down. If I delete all the events that uses variables for "size". It stops the leak...

image