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.

Coding > Memory managers...your thoughts?

#4481 - regularkid - Tue Apr 01, 2003 8:14 am

Hey, guys. Since i've been having memory problems lately (most of you have probably read my posts), I decided I needed a way to figure out how much memory I am using. So I think I need to write a memory manager. My first idea is to have a "dummy" file compiled at the end of my makefile. This file will have nothing but two variables in it. One that is a normal u8 and another that is a const u8. So, my thinking is that the compiler will put these at the end of my stuff in RAM and in ROM. So, then all I should need to do is read the address of each of these and subtract the starting address of RAM and ROM and viola! I will know how much memory is being taken up in each! Thoughts? Ideas? Comments? Thanks!
_________________
- RegularKid

#4482 - Quirky - Tue Apr 01, 2003 11:39 am

I use a combination of map and Visualboy Advance's memory viewr to see how much memory I'm using up.

Try adding
Code:
-Wl,-Map,mygame.map
to your LDFLAGS - it will produce exactly what you need without having to do what you described. The map file tells you, amongst other things, the list of common symbols, their size, their memory location, the memory location of your routines, etc etc. It's very useful and will show you if, for example, some const data is unexpectedly going in RAM and not ROM, which I think could be a cause of your problems.

#4505 - regularkid - Wed Apr 02, 2003 4:09 am

Awsome! That is so cool! Thanks!
_________________
- RegularKid