PDA

Voir la version compl鋈e : [無ibrary][R廥olu] memory leaks during multiple image loading


kewnt
08/07/2008, 20h15
hi.

i need to load multiple images, one after another and it looks like there's a memory leak somewhere... maybe you can advise me ob where should i do some free()-s?
for now i just load images w/ ulLoadImageFilePNG and do not make any free().
like this:

if(updated) {
updated=0;
readsizes(coords[2][0]);
a=readimg(coords[2]);
maps[2]=ulLoadImageFilePNG((void *)buf, (int)a, UL_IN_VRAM, UL_PF_PAL8);
a=readimg(coords[3]);
maps[3]=ulLoadImageFilePNG((void *)buf, (int)a, UL_IN_VRAM, UL_PF_PAL8);
readsizes(coords[1][0]);
a=readimg(coords[1]);
maps[1]=ulLoadImageFilePNG((void *)buf, (int)a, UL_IN_VRAM, UL_PF_PAL8);
a=readimg(coords[0]);
maps[0]=ulLoadImageFilePNG((void *)buf, (int)a, UL_IN_VRAM, UL_PF_PAL8);
}



thanks!

kewnt
17/07/2008, 10h54
so, any ideas how can i properly free the memory and unload images in order to load the new ones?

Michoko
17/07/2008, 12h53
What about using :

void ulDeleteImage ( UL_IMAGE * img ) (as explained here (http://brunni.dev-fr.org/ulib/doc/doxygen/group__images__creation.html#g046f7855d9ae5de6c46d 2ecd332e5f94))

So calling ulDeleteImage(maps[2]) should free your first loaded image, for example.

kewnt
17/07/2008, 13h21
What about using :

void ulDeleteImage ( UL_IMAGE * img ) (as explained here (http://brunni.dev-fr.org/ulib/doc/doxygen/group__images__creation.html#g046f7855d9ae5de6c46d 2ecd332e5f94))

So calling ulDeleteImage(maps[2]) should free your first loaded image, for example.

Michoko, man, u helped me much...
I'm such a idiot! Dunno how could i miss this function in teh documentation! I was sure i read it!

Anyway, it works great now, thanks again!