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 

PSP and memory allocation

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



Joined: 04 Apr 2006
Posts: 2

PostPosted: Tue Apr 04, 2006 10:35 am    Post subject: PSP and memory allocation Reply with quote

Hello all.

I'm a newbie to PSP programming. I'm trying to allocate memory using the malloc() function but the PSP always freeze once I allocate more than one block of 2MB size.(ie second 2MB block cannot be allocated and I'm getting this in my error log just before the PSP freeze:
malloc 65536 by rtarea
malloc 2097152 by fast
malloc 65536 by filesys
malloc 524288 by kick
malloc 2097152 by chip
Fatal error: out of memory for chipmem.
)

I suppose there is 32MB of memory avaliable?
(My first attempt is to enhance emulated memory in PSPUAE Amiga emulator - http://www.kaillera.com/pspuae/pspuae-0.41-src.zip)

Is there any good information about the PSP memory and its proper handling/usage when doing homebrew apps?

Thanks for any tips, hints etc. and sorry if this topic was discussed already here.
Back to top
View user's profile Send private message
PeterM



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Wed Apr 05, 2006 3:20 am    Post subject: Reply with quote

I don't think all the 32MB is available for allocation. Depending on your memory usage and global/static data size you'll probably find it's closer to 20-25MB.

Which kinda sucks...
Back to top
View user's profile Send private message Visit poster's website
subbie



Joined: 05 May 2005
Posts: 122

PostPosted: Wed Apr 05, 2006 3:23 am    Post subject: Reply with quote

I though 24MB is open to an app (the 8MB is locked away by the kernal for prx modules).

Of that 24MB you must take into consideration stack space, static varibles & the application it self.

Yet other then that you still have alot to work with. I'm having no problem loading up 16MB rom files for my n64 emu.
Back to top
View user's profile Send private message
cyphre



Joined: 04 Apr 2006
Posts: 2

PostPosted: Wed Apr 05, 2006 5:07 am    Post subject: Reply with quote

Yeah, I read somewhere that 8MB is used as 'kernel space' and the rest 24MB is used for 'application space'.
I also know that other apps(emulators etc.) are able to allocate quite big chunks of mem. So that's why I wonder what could be the problem with the Amiga emulation. I think 24megs should be sufficient.
Is there a way how to get currently used/free memory at runtime?
I even tried to use sceKernelTotalFreeMemSize() and sceKernelMaxFreeMemSize() methods from PSPSDK package to see how much memory on the PSP is available but I got strange results:

total free mem 1028096bytes
max free mem block 966656bytes

Any help from PSP homebrew coding guru is appreciated.
Back to top
View user's profile Send private message
johnmph



Joined: 23 Jul 2005
Posts: 119

PostPosted: Wed Apr 05, 2006 6:26 am    Post subject: Reply with quote

cyphre wrote:
Yeah, I read somewhere that 8MB is used as 'kernel space' and the rest 24MB is used for 'application space'.
I also know that other apps(emulators etc.) are able to allocate quite big chunks of mem. So that's why I wonder what could be the problem with the Amiga emulation. I think 24megs should be sufficient.
Is there a way how to get currently used/free memory at runtime?
I even tried to use sceKernelTotalFreeMemSize() and sceKernelMaxFreeMemSize() methods from PSPSDK package to see how much memory on the PSP is available but I got strange results:

total free mem 1028096bytes
max free mem block 966656bytes

Any help from PSP homebrew coding guru is appreciated.


http://forums.ps2dev.org/viewtopic.php?t=4784
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