You are not logged in.

#1 2008-08-20 21:05:12

JustWoody
Member

freeing textures crashes

Not sure if anyone has come across this, but some times when I try to free some texture memory, my game does a code dump :-(

The textures do exist as I am displaying them on the screen, but for some reason some of them always or after a while dump

Heres the type of code

Code:

    if(tex_tiles) free(tex_tiles);

Does anyone have any ideas what might be causing this? or any other things that I should be doing when trying to clear down memory usage.

For a bit more info - This mainly happens when I go between different part of my game (e.g. between game and menu) when I do this I clear down all my game graphics and reinitialise all the menu graphics

Offline

 

#2 2008-08-20 22:44:47

Crayon
Bad Mother Fucker

Re: freeing textures crashes

I have been having some problem with my game generating dumb when my application is ending (not always). Before exiting I'm freeing everything, but I was not sure of the cause. Maybe it's related to that issue?

I'm using the same code has you to clear the memory:
http://grrlib.santo.fr/forum/viewtopic.php?id=46

Here is a quote from RedShade:

RedShade wrote:

I believe free(ptr) is the correct way to free memalign-ed memory

- http://grrlib.santo.fr/forum/viewtopic.php?pid=149#p149

Offline

 

#3 2008-08-21 09:19:31

JustWoody
Member

Re: freeing textures crashes

So I am doing what is recommended, but this still causes memory leakage.

For some background - I've probably got about 40 or 50 pngs in my whole game although only a few of these (max 12) are even assigned through GRRLIB_LoadTexture at any one time.

Does anyone know of any code analysis tools that look for the likes of memory leakage that I can run over my code within the programmers notebook?

Offline

 

#4 2008-08-22 10:46:09

JustWoody
Member

Re: freeing textures crashes

I've now stopped the crashing by only free-ing the resources on exit from the whole application instead of between different stages, along with checking to see if the textures have already been loaded on initialisation of each stage.

Offline

 

Board footer

Powered by FluxBB