ok yea..that was a bad example.. well im not sure why what is happening to me is happening then.. i load up say maybe 40-50 pictures..different sized pictures..and free them all eventually.. and in the same program i load up a mp3 file, and play it.. it crashes..if i try a small mp3 file, it works fine..
now if i take the code that plays the mp3 file into a separate program..the big mp3 file will load and play fine.. so that leaves me to beleive the images i load and free..are not clearing memory completly..or is there some way i can .. like defrag the memory..heh.. so the mp3 has room to be loaded into?
free'ing memory
Call malloc/free as few times as possible. If you are loading up a bunch of bitmaps, load up enough memory to hold your framebuffer ( 480x272x4bytes ) and write to that buffer whenever you load up an image. When you load the image, call malloc to grab enough memory to hold the file and then free it imediately afterwards, or better yet make a dedicated file-read buffer that is only created once.
This will cut down on the amount of memory fragmentation. Remember, you've only got about 20MB of real RAM to work with once your executable is loaded up. This is NOT a lot!
This will cut down on the amount of memory fragmentation. Remember, you've only got about 20MB of real RAM to work with once your executable is loaded up. This is NOT a lot!
It's a lot more than PS1!! And we fitted a lot in that. As long as we have the reasonable expectation that if we free everything we malloc there is no fragmentation that is OK. And as long as the C++ object allocations aren't mental then there is some chance of reliable software.
Jim
PS. It's a lot more ram than N64 and DC.
Jim
PS. It's a lot more ram than N64 and DC.