PDA

View Full Version : Memory problem with 8x8 sprites


stengun
09-05-2003, 08:59 AM
Hi,

I'm getting the following message when I exit from my app:

Module failed to free all memory.

I've tracked this down to the fact that I'm using a 8x8 sprite TPage. If I replace this with greater size, 16x16 for example, the problem goes. Has anyone else experienced this?

Thanks in advance

kUfa
09-06-2003, 06:24 AM
Check your memory allocation:

- for every CreateInterface, do you have a release call?
- for every malloc, do you have a free?

regards,

/kUfa

stengun
09-06-2003, 07:48 AM
This problem seems to be with 8x8 sprites. I can change the code to use 16x16 with same number of allocs and frees and all is fine. I do need to use 8x8 in my final code though.

kUfa
09-06-2003, 07:58 AM
Well there is another bug in your code... i often use 8x8 pictures (but quiet rarely have separate files, i make a big picture) and never had such problems..

Btw you can have memory leaks on the phone (not the emulator) if you use png on the t720 if i remember right (you can check on the forum)

Do you have a safe mem alloc (that checks for all free calls at then end of your programm) ? Note that if everything seems to be ok, it is not necessary the case.. Especially on brew emulators <2.0 ..

But definitely there is some bug in your bug, or in the emulator...
Trying mixing the pictures in a big one, use convertbmp and blitblt, you will have much more faster results and loading time!

/kUfa

stengun
09-06-2003, 08:08 AM
I've used the example code called spritegame, and changed one of the TPages to use 8x8s. This causes the error. So I dont think its anything I've done. Im begining to think it's an emulator problem, as I doubt the example would be bad, although there is always that possibility.

kUfa
09-06-2003, 08:11 AM
Well, i dont have this example...

/kUfa

kUfa
09-06-2003, 08:12 AM
But maybe i just have sdk 2.0.. can you put the sourcecode of your buggy application here?

/kUfa

stengun
09-06-2003, 08:27 AM
here is the example

I'm using BREW 2.1 SDK and emu

kUfa
09-06-2003, 08:33 AM
Thx i ll have a look and try to use 8x8 tiles!

/kUfa

Dragon
09-06-2003, 01:16 PM
stengun,

It's most definitely an error on your behalf, not deallocating all the memory your application has allocated.

Make sure to release all memory allocated by any MALLOC and new operation. Sometimes you will have to go through your code line by line to find out where you missed something.

For that reason I've overloaded the new and delete operators as well as MALLOC and FREE with my own implementations to keep track of allocations. If there are problems I can easily go in there and see which block has not been released.

stengun
09-09-2003, 06:35 AM
Ok, got it sorted:

It turns out to be a tilemap problem. You need to call ISPRITE_SetTileBuffer with a NULL page to free up the existing one on exit. This is a bit strange as the mem error only occurs with 8x8s. Larger sizes dont show up the error, and I would expect the SPRITE release to do this anyway, but obviously doesnt.

Oh well, sorted now. Thanks guys for looking into it.

kUfa
09-09-2003, 09:32 AM
Hehe was too busy to check it out, but well done!

/kUfa