forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting the free memory

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Shapyi



Joined: 25 Apr 2005
Posts: 95

PostPosted: Tue Apr 11, 2006 9:52 am    Post subject: Getting the free memory Reply with quote

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
View user's profile Send private message
white rabbit



Joined: 06 Jul 2005
Posts: 60

PostPosted: Tue Apr 11, 2006 6:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Garak



Joined: 27 Jul 2005
Posts: 46

PostPosted: Thu Apr 13, 2006 4:56 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
Gary13579



Joined: 15 Aug 2005
Posts: 93

PostPosted: Thu Apr 13, 2006 10:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group