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 

Where did my memory go? (10-12M non malloc'able)

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



Joined: 26 Mar 2009
Posts: 33
Location: holland

PostPosted: Fri Apr 17, 2009 6:18 am    Post subject: Where did my memory go? (10-12M non malloc'able) Reply with quote

Hi,

I was investigating an out-of-memory crash, and I found that malloc doesn't alloc all available memory:
Code:

  int tmalloc = 0;
  while (malloc(1024) != NULL)
    tmalloc += 1024;
/*   while (malloc(1024*1024) != NULL) */
/*     tmalloc += 1024*1024; */
  printf("tmalloc = %d\n", tmalloc);
  /* FW 1.50 => 10910720 / 10485760 (normally 24000kB) */
  /* FW 5.00 => 39819264 / 39845888 (normally 52500kB) */


The test, by malloc'ing blocks of 1kB or 1MB, always leaves a good 10-12MB untouched.

I'm running the tests on a PSP2, first with firmware 1.50(+3.40hw), then from 5.00 M33-6, compiled as .prx and run from PSPLink.

My .prx is around 2.2.MB.
When I strip my application to get a minimal main that only does the test, I go back to 53000k.

Any clue? :)


Btw, even with a minimal program and just checking sceKernelTotalFreeMemSize(), we loose 8-10MB from the start (24M PSP1 / 53M PSP2). How comes? :/
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri Apr 17, 2009 10:24 am    Post subject: Reply with quote

Like most OSes, the OS in the PSP is loaded from rom into ram. So that "missing" 8 to 10 MB is mostly kernel code and data. Some of the rest is the size of the app loaded. The rest are the user mode PRXs loaded that allow your app to load, run, and call the kernel.

As to the first part, what are you using to define the heap size in the app? I normally use something like "PSP_HEAP_SIZE_KB(-256);", which means gimme everything except for 256 KB.
Back to top
View user's profile Send private message AIM Address
Beuc



Joined: 26 Mar 2009
Posts: 33
Location: holland

PostPosted: Sat Apr 18, 2009 4:50 am    Post subject: Reply with quote

J.F. wrote:
As to the first part, what are you using to define the heap size in the app? I normally use something like "PSP_HEAP_SIZE_KB(-256);", which means gimme everything except for 256 KB.


I found that I have 10M of data segment (.bss) in my executable (e.g. static struct arrays), which looks like the main culprit here :)

I'm still puzzled at why the missing size is different when running under 1.50 and 5.00.

J.F. wrote:
Like most OSes, the OS in the PSP is loaded from rom into ram. So that "missing" 8 to 10 MB is mostly kernel code and data. Some of the rest is the size of the app loaded. The rest are the user mode PRXs loaded that allow your app to load, run, and call the kernel.


Thanks. I was under the impression that the main OS was unloading itself before running a homebrew, but maybe that's just an impression :/

And there's the additional SEPLUGINS, indeed.
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