PSP and memory allocation

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
cyphre
Posts: 2
Joined: Tue Apr 04, 2006 10:12 am

PSP and memory allocation

Post by cyphre »

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.
PeterM
Posts: 125
Joined: Sat Dec 31, 2005 7:25 pm
Location: Edinburgh, UK
Contact:

Post by PeterM »

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...
subbie
Posts: 122
Joined: Thu May 05, 2005 4:14 am

Post by subbie »

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.
cyphre
Posts: 2
Joined: Tue Apr 04, 2006 10:12 am

Post by cyphre »

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.
johnmph
Posts: 119
Joined: Sat Jul 23, 2005 11:48 pm

Post by johnmph »

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
Post Reply