| View previous topic :: View next topic |
| Author |
Message |
Shapyi
Joined: 25 Apr 2005 Posts: 95
|
Posted: Tue Apr 11, 2006 9:52 am Post subject: 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? |
|
| Back to top |
|
 |
white rabbit
Joined: 06 Jul 2005 Posts: 60
|
Posted: Tue Apr 11, 2006 6:17 pm Post subject: |
|
|
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). |
|
| Back to top |
|
 |
Garak
Joined: 27 Jul 2005 Posts: 46
|
Posted: Thu Apr 13, 2006 4:56 am Post subject: |
|
|
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[i] = malloc(100000);
if(ramAdd[i] == 0) //malloc failed
{
ram = (float) i;
int z = 0;
for(z=0; z<i; z++)
{
free(ramAdd[z]);
}
break;
}
}
return(ram/10);
} |
|
| Back to top |
|
 |
Gary13579
Joined: 15 Aug 2005 Posts: 93
|
Posted: Thu Apr 13, 2006 10:35 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|