kernel heap size
Posted: Fri Dec 02, 2011 1:19 am
I have discovered that the initial kernel heap size is too low for my needs. In libogc/system.c is
#define KERNEL_HEAP (1*1024*1024)
If I adjust this size to 2mb (change 1 to 2 there) then my program works. The underlying issue is I create too many threads with a large stack size, 128kb. The stack is allocated from the heap/workspace thing which is the same size as the kernel heap. 1mb / 128kb is roughly 8, so if you subtract a handful of other objects that already use the kernel heap that leaves 7 threads. My program runs into this limit and fails.
I don't actually needs 128kb, that is just an upper limit to make me feel safe. The actual limit I need is somewhere between 64kb and 128kb but I am not happy about trying to figure out exactly how large to make it. If I make it to small then the program will ultimately crash in some other place.
Would it be possible for SYS_Init() to accept a u32 which defines the kernel heap size? Possibly there could be an extra function to preserve backwards compatibility, SYS_Init_Heap(), which SYS_Init can call with KERNEL_HEAP.
#define KERNEL_HEAP (1*1024*1024)
If I adjust this size to 2mb (change 1 to 2 there) then my program works. The underlying issue is I create too many threads with a large stack size, 128kb. The stack is allocated from the heap/workspace thing which is the same size as the kernel heap. 1mb / 128kb is roughly 8, so if you subtract a handful of other objects that already use the kernel heap that leaves 7 threads. My program runs into this limit and fails.
I don't actually needs 128kb, that is just an upper limit to make me feel safe. The actual limit I need is somewhere between 64kb and 128kb but I am not happy about trying to figure out exactly how large to make it. If I make it to small then the program will ultimately crash in some other place.
Would it be possible for SYS_Init() to accept a u32 which defines the kernel heap size? Possibly there could be an extra function to preserve backwards compatibility, SYS_Init_Heap(), which SYS_Init can call with KERNEL_HEAP.