Windows Memory problem when saving from surface?

D

dna48

Guest
Hello,

I am having a problem when saving repeteadly from a surface into a file (on Windows). Either when using save surface or when using a sprite in the middle and saving the sprite. After doing it repeatedly enough the memory consumption grows and grows, even without painting anything at all on the surface
I have tried freeing the surface, the sprite even the file_find every here and there but no matter what it keeps growing. Maybe i should use a buffer? If that is the case, has anyone info about how saving a surface to a buffer and save buffer into png?

I have attached a gmz file. Start on debug mode to see memory graph (or windows task manager)

https://ln.sync.com/dl/040b64000#sxtbfzkd-gzyqgf72-smxjnqvi-dx88jmkb

What i am doing wrong?

Thanks
 

jo-thijs

Member
First of all, you're using file_find_close wrongly.
file_find_close has to be called after using file_find_first and is meant to free memory usage of that function, not of anything else.

Secondly, you're not saving your sprite as png file (not that important, but ).

Thirdly, there's no use for the alarm 0 event and the only use for the create event is initializing surf, surfw and surfh.
A lot of the stuff in the draw event doesn't serve any purpose either.

Fithly, why the irandom(25)==1? It only makes testing more difficult.

Finally, the memory leak seems to be caused by sprite_save only (which should not be executed in the draw event, but it doesn't matter here).
This is probably some bug in GameMaker. You can report it here: http://www.yoyogames.com/bug
 
D

dna48

Guest
Zeroly,
(a) Thanks for replying,
(b) the numbering lesson
(c) I have prepared this in 5 minutes just to try to easily show the problem. It is not a thesis.
Firstly, I know about the file_find_close but i have done so many tests that i included this just in case. It is in the comments. I have been trying every single "clear", "free" and "close" possibility in gamemaker before opening a bug.
Secondly, it is indeed saving as png, i am just not including the extension but it does not matter because i am not drawing anything either, the case here it is the saving of the files, not the artistic value to be displayed. The surface is empty and the extension could be .peppapig but the file format would still be successfully opened by any png reader.
Thirdly, and fourthly (?) refer to 0c
Fifthly, irandom(25) is an easy way (5 mins) statistically reduce the number of times i am writing to file. I want to show a problem, not get an out of memory in 5 seconds, with irandom(25)==1 it takes 25 times more time so it is very evident to any one using the task bar or the debugger how the memory grows and grows just by saving multiple files.
Endly :). That is what i thought.
 
Last edited by a moderator:
Top