Alberto
Joined: 12 Feb 2007 Posts: 57 Location: Sofia
|
Posted: Fri Aug 06, 2010 8:06 pm Post subject: Checking available memory |
|
|
Hi all.
Let me explain first...
I know that using malloc the PSPSDK initiates its own MM, allocates almost all of the memory, then provides me with what I need, but rendering sceKernelFreeMemory (or whatever it's named) not useful to retrieve the amount of free memory available.
Hence I wrote a simple procedure that will try to allocate blocks of memory (as it fails, it divides the block-size by 2 and tries again) till no memory is available and the block-size is 1...
So far, it appears to work good.
I notice, thou', then fopen'ing a file, and then fclose'ing it, leaves a memory leak. It varies in size, but for a 100-bytes text file it is like 392bytes. It may be bigger with images etc. etc.
Is it by design? Has it something to do with internal memory aligning?
Is my memory-check algo not working (so I may ask if there are any other ways - like maybe there are already functions of the internal MM, their prototype just not being yet exported in the .h file - I can check the free memory?
I need it just to double-check I am actually freeing all what I allocate; as I always write malloc's/new's and free's/delete's _together_, but you never know... ;-)
Cheers, A. |
|