Getting the free memory
Getting the free memory
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?
-
- Posts: 60
- Joined: Wed Jul 06, 2005 7:03 pm
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);
}
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);
}