GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2009-07-06 19:33:15

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Memory leak while deleting sprites

Hi everybody, I've noticed something that was pissing me off in my game. I am using an external map editor for my game. However I need to load sprites and delete them after their use so that I can load another map using sprites that this map needs only.

The problem is that after loading a new map 10 times in a row, the memory usage would grow from 50,000K to 60,000K even though the map was the same (which seemed logically impossible).

Then I did some tests and rapidly came to that conclusion: sprite_delete() doesn't free all used memory. How I did it? I simply looked at the memory usage with of  game maker with one object, then looked at it when this object loads 100 times the same sprites and finally looked at it when I delete all these sprites.

The memory usage went from:

10,000K to 175,000K to 12,000K (which is not what it is expected). We are loading sprite and deleting them. it should come back to 10,000K but it is not.

Here's the editable I used to test it: http://willhostforfood.com/?Action=down … leid=73447

Note:
Start the game, look at the memory usage. Then press space and look at the memory usage again. Finally, press enter (to supposedly free all the memory used by the sprites). You will notice that the memory usage won't come back at the amount you saw the first time you looked at it.

Can anybody confirm this?

Offline

#2 2011-05-10 23:09:41

Daniel
Member
Registered: 2011-05-04
Posts: 25

Re: Memory leak while deleting sprites

When I encounter something like this, I usually just assume it's some sort of Caching and continue.

For example, when loading a sprite, perhaps it is scanned and the hitmap is generated, which is then stored in memory in case later on you load that sprite again.

I have no clue if this is the case, however, it's the kind of thing I always assume is happening, so I don't spend another 30 minutes doing tests when I should be working on my project.

Offline

#3 2011-05-11 01:05:54

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: Memory leak while deleting sprites

GM's memory management seems bizarre sometimes. I don't know how many times I've thought I've spotted a memory leak when a few more moments later it mysteriously melts away.


Abusing forum power since 1986.

Offline

Board footer

Powered by FluxBB