GP32 New Sdl Game Help


MattPurland

Still Fresh
Joined
Jun 26, 2006
Messages
38
Hi,

I've just started learning to program in SDL and have come up against a problem. I've just started writing a 2D bottom-up scroller (think 1942) but the problem being its eating up memory by the mb and I have no clue why. The source can be found here and if anyone could give me any pointers I'd be very thankful. The source is currentlt written for Windows using bloodshed.

Cheers!

Bah, could someone move this to the GP2X dev board? Thanks =/
 
It seems to me as if you are loading the fonts and images every iteration of the main control loop.
 
EDIT: digitaljez answers faster than I do...

Maybe just because your loading your font/images at each loop...
Loading them at the beginning should be enough ;)

something like :

// Load Fonts
loadFonts();
// Game Stuff
//load images, fonts, etc
loadGameImages();

//While the user hasn't quit
while( quit == false )
{
...


and remove calls from the main loop

Thor
 
Cheers, that's helped alot! It's still eating up memory but nowhere near as fast as it was. So I've moved the loading of fonts and game images. Anything else you can see?

Cheers!
 
Yes. That was a totally stupid suggestion. Are you sure you have removed both loadFonts() and loadGameImages(); ? I can not see anything in there that could be eating memory. Those commented menu calls do not want to be inside that loop when you get round to implementing them. Maybe you could update the archive so it is in its current state in case something new has crept in.
 
Sorry. I can't see what the problem is. This calls for a hardcore code master - hopefully one will drop by. Good luck with it.
 
If I remember correctly "TTF_RenderText_Blended" creates a surface which means that you are creating a new SDL_Surface every loop without freeing it. Add SDL_FreeSurface(title) at the end of the while loop should fix it.

Edit: Although be careful, the Cleanup function also does SDL_FreeSurface(title) as well.
 
rtb7 posted on Aug 3 2006 at 07:24 PM said:
so, just remove the title creation from the loop and put the it with the loading calls.
Or you could do that which would be far more better. :)
 
Last edited by a moderator:
Back
Top