SDL2 memory overflow on minimize

i was writing a game in sdl2 (and lua 5.2 for modding). while i was trying to optimize the game i minimized the window, i saw the memory multiply in windows task manager then my computer froze. after restarting my computer, i went to a program i made a few days ago. i minimized the window and there was not memory overflow.

what might cause this memory overflow?
Unfortunately the 'cause' and the problem do not seem to be related, so it could really be any number of things. A lot more information about your program is going to be necessary to figure out the answer to this problem.
would testing for a mouse event while minimized cause it and if so how would i test if the window is minimized?
Last edited on
I doubt it, but this problem will likely be nigh impossible to diagnose without me reading and understanding your entire program. You may want to consider running your program in a debug mode or something so you can catch an out of memory error and see what the program is doing at that point, as I'd expect it is probably a lot of the same allocation request in a loop or something that is causing the problem.
Obviously you have a memory leak inside of a loop. We can't do much to help you without seeing your code.
i don't like putting my source code on a public site.. oh well! i have compressed my project file here:

no one has responded so im getting rid of the link

note: i'm very unprofessional when it comes to comments (sorry)
Last edited on
*bump*
well after some diagnostics i figured out that i was rending the whole time. well when you would minimize the screen there is nothing to render to. so it causes a memory overflow. to counter this, i put the render function into a statement testing for if the window is minimized. if it is minimized don't render! one thing i can't seem to figure out is why it goes up in cpu when minimized. i don't care about cpu going up when minimized i just don't want the users computer crashing because of my program.

quick summary: don't render when minimized!
OP said:
i put the render function into a statement testing for if the window is minimized.

And
OP said:
i can't seem to figure out is why it goes up in cpu when minimized.


My crystal ball tells me that these two things may be related somehow. You are better off capturing the system messages to the window and keeping track of it's state that way. You need someway to defer CPU time from your program when it is minimized. Unfortunately I have spent too much time away from SDL to remember what the equivalent of SFML's sf::Window::waitEvent() is.

Why don't you like posting your code?
Why don't you like posting your code?


i hate to admit it but i'm not the open source type of guy (it might be because of how messy my code can be at times).
Last edited on
Topic archived. No new replies allowed.