This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Heap and Stack Usage


Is it possible to limit the heap size? My understanding is that dynamic memory allocation occurs through the use of sbrk() when memory is needed via malloc, etc. If the memory is available, a pointer is returned to the block. If there is not enough memory, the heap is expanded by 4k increments (sh target). My understanding is that the heap will grow until the top of the heap overlaps the stack. Looking at the sources is appears that the new top of heap is checked against the stack pointer and if the allocation would cause the heap to expand beyond the stack pointer, a null pointer is returned indicating not enough memory. Since the stack pointer tends to be volatile, this could cause problems unless there is plenty of memory for stack and heap. My question is whether you can put a hard ceiling on the heap independent of the stack pointer, thereby creating a fixed-size area that is exclusively used by the stack. I read a reference on brk() in glibc documentation but brk() was undefined in my implementation which is sh-elf.

Thanks,
John

AMT-Datasouth
jlowen@amtdatasouth.com
http://www.datasouth.com
(704)523-8500 ext. 132




------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]