gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Profiling memory usage with the gba

#25321 - rmy - Fri Aug 20, 2004 4:13 pm

Does anyone has a trick for profiling the memory usage on the GBA? Tricks for checking for memory leaks would be nice too.

#25324 - poslundc - Fri Aug 20, 2004 4:35 pm

Profiling: nm -n on your .elf file will show you all of the symbols and their positions in memory, sorted by order. You can easily use this to determine your memory consumption.

Memory leaks: avoid using dynamically allocated memory. :P

Dan.

#25417 - rmy - Sun Aug 22, 2004 3:48 pm

Thanks.
Profiling global and static variables is interesting too. But unfortunately dynamically allocated memory (allocated with the C++ new keyword) is what interests me most.

I did some tracking of allocation and dealloction using operator new on a different platform a few years back. Perhaps this is the way to go on the GBA too...

#25420 - lordmetroid - Sun Aug 22, 2004 5:10 pm

It is true, one should avoid using dynamic allocated memory...
However if you need to allocate memory sometimes due to your vaiables can possible grow so big it will hurt to have lots of memory in an array never being used because the possibility exists for it's usage...
You can make an array and make pointers pointing to different parts of that array, and so you will have allocated memory the hardcore way...
This demands some experience to abuse pointers from the coder though!
_________________
*Spam*
Open Solutions for an open mind, www.areta.org

Areta is an organization of coders codeing mostly open source project, but there is alot of sections like GBA dev, Language learning communities, RPG communities, etc...

#25460 - rmy - Mon Aug 23, 2004 1:11 pm

After doing some tests on allocating and deallocating lots of objects, it seems that the memory manager sooner or later crash (memory gets fragmentet)?

Having lots of objects preallocated in an array is a possible approach, but that means that I cannot have too many different classes representing in-game characters in my object hierarchy.

BTW: Your "SPAM link" should link to some content. ;-)