You are not logged in.
Brief Description: Multiple use of sprite_replace and background_replace with PNGs leaks memory
GM Versions: GM7
References: <none>
Example File: http://www.forge.dds.nl/files/pngmemleak.zip
Bug Confirmed: ---
Hardware Dependent: No
Main Info:
Using multiple calls to background_replace and sprite_replace to replace a background or sprite resource, using PNG image files of different (!) file sizes, causes the game's memory consumption to increase.
Load the example file into Game Maker 7. Hit CTRL+ALT+DEL and bring up the Processes list. Make sure the column Peak Mem Usage is visible and run the game. You will see memory consumption rise gradually.
The issue is most likely related to the routines used to allocate and deallocate memory to process PNG images.
Workarounds:
1. Use Game Maker 6. The leak has been introduced with version 7.
2. Use BMP, GIF or JPG images instead (the issue only applies to PNG images)
3. Use sprite_delete / sprite_add and background_delete / background_add to replace images.
Offline
I can indeed confirm this bug, seems to happen independent of the arguments (apart from the file), and also happens for background_replace_alpha..
Offline
Good catch. Then I'm guessing it also happens for sprite_replace_alpha.
Offline
Interesting. I will take that in consideration if I need it later on. However I suggest everyone making any game to use an external resources system as well as a simple editor for their game.
Offline
Does it drop after running for a long time? It could simply be memory fragmentation.
But one thing you will notice, commentout image1's loading and load image 2... The memory climbs but not as fast
Comment out image2 and uncomment image 1 and the memory is somewhat stable after a few seconds; the memory climbs about 8 k evey 20 seconds...
Offline
Well I ran the program for around 15 minutes and it was stilling climbing after that..
Offline
I can report similar results over a longer period of time.
Abusing forum power since 1986.
Offline
Does it drop after running for a long time? It could simply be memory fragmentation.
But one thing you will notice, commentout image1's loading and load image 2... The memory climbs but not as fast
Comment out image2 and uncomment image 1 and the memory is somewhat stable after a few seconds; the memory climbs about 8 k evey 20 seconds...
That's why I indicated that PNGs of different file sizes have to be used to reproduce this bug, and why you also have to look at the peak memory use (regular memory consumption fluctuates so much that it's difficult to discern a leak). If you'd replace the image with a copy of itself you'd never notice.
Offline
Unless the game ran for a week or something, it still leaks by 8 k every 20 second when same replaces same for the small one.... But for the large one it's more obvious. Different size seems to accelerate the leak. PNG of different size does not need to be used, but it helps to see it sooner. That was my observation at least. Sorry if I was not clear.
Offline
Just to state the obvious: this bug has been fixed in the beta.. (I suspect it was due to the preloading, which has been removed).
Offline
Not obvious at all, thanks for checking that out. Confirmation, anyone?
Abusing forum power since 1986.
Offline
No, it still leaks.
Offline
Great. Another "fixed" bug that has reappeared in the release version. WTF, YoYo? Get your act together.
Abusing forum power since 1986.
Offline