i saw this function and i was wondering can i allocate more heap like it says and if so what good does it do me could i reallocate the currently used heap defined from PSP_HEAP_SIZE(-5000)
Instead of sceKernelAllocPartitionMemory which allocates a free memory block from raw memory partition (which has some memory overhead for each allocation and is inefficient for multiple allocations), you can allocate a big heap from the raw partition and sceKernelAllocHeapMemory will sub-allocate from the heap more efficiently.
I don't know about the internal workings of PSPSDK, but just as a wild guess, maybe it creates a heap with this same function and malloc and stuff is redirected to that heap. So if you knew the heapid you might be able to resize it. Just a guess.
coolkehon wrote:well if i can get the heap id or i already have a heap then how can i realloc an already existing heap i didnt see any reallocate for it
I didn't see any resize function either :P
Basically PSP_HEAP_SIZE(x) is analogous to heapid=sceKernelCreateHeap(2, x, ...);
And malloc(y) is like sceKernelAllocHeapMemory(heapid, y);
Last edited by Torch on Wed Mar 11, 2009 9:21 pm, edited 1 time in total.
oh ok so i was confused sceKernelAllocMemory allocates from all the free memory the psp has in the partion id and sceKernelAllocHeapMemory allocates memory from a heap well then how would i set malloc to allocate memory from another heap
coolkehon wrote:oh ok so i was confused sceKernelAllocMemory allocates from all the free memory the psp has in the partion id and sceKernelAllocHeapMemory allocates memory from a heap well then how would i set malloc to allocate memory from another heap
It would probably prove problematic. The PSPSDK doesn't allocate the heap from the partition until the first time you allocate memory using malloc or whatever. Until then all the memory in the partition will be free. So if you never use malloc, you can create your own heap with the sce functions and allocate using the sce functions.
Unless there is some way to change the heapid that the PSPSDK uses in malloc, you probably can't delete it's heap and create a different sized one at runtime. Assuming that it even uses the sce functions to create a heap in the first place.
coolkehon wrote:so where do things like local variables and functions and function calls go in memory are they also in the same heap
also oslib crashes when i call oslInitGfx and there isnt enouph memory so i was hoping to fix this somehow
Variables and functions declared in the code are statically allocated in memory when the executable is loaded by the OS. The remaining memory in the partition after this is available for allocation as a heap or whatever.