Getting the free memory

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Shapyi
Posts: 95
Joined: Mon Apr 25, 2005 9:31 am

Getting the free memory

Post by Shapyi »

Is this a built in pspsdk function to get the current amount of free RAM so that I get an idea of how much memory my program is using on PSP?
white rabbit
Posts: 60
Joined: Wed Jul 06, 2005 7:03 pm

Post by white rabbit »

If you do a search you will turn up some stuff.

Somebody has written some code to find both out for you, and there are tricks you can do for raw free ram. (largest available block is more difficult but the code is there too).
Garak
Posts: 46
Joined: Wed Jul 27, 2005 1:59 am

Post by Garak »

I don't take credit for this, and I forgot the name of the guy who wrote it. If you do a search, you will find the origional post containing this code. This bad boy works like a charm, and has helped me out something fierce.

Garak


float GetFreeRam()
{
float ram = 0;
int i = 0;
int ramAdd[320];

for(i=0; i<320; i++)
{
ramAdd = malloc(100000);
if(ramAdd == 0) //malloc failed
{
ram = (float) i;
int z = 0;
for(z=0; z<i; z++)
{
free(ramAdd[z]);
}
break;
}
}
return(ram/10);
}
Gary13579
Posts: 93
Joined: Mon Aug 15, 2005 7:43 am

Post by Gary13579 »

The code pasted above works, and I used it for a while, but I replaced it for this.
It works, and returns bytes instead of megabytes.
Post Reply