Heap and Stack Usage

Hua Ji hji@netscreen.com
Fri Jun 15 11:46:00 GMT 2001


	/* Check against rlimit and stack.. */
	rlim = current->rlim[RLIMIT_DATA].rlim_cur;
	if (rlim < RLIM_INFINITY && brk - mm->end_code > rlim)
		goto out;


So change the default resource limit so that you can constrain the brk value
expending.

You don't have to read libC stuff, which is not related to the questoin you
talked below. Please
read the sys_brk() system call for details.

Wish helpful,

Mike

-----Original Message-----
From: John Lowen [ mailto:JLowen@amtdatasouth.com ]
Sent: Friday, June 15, 2001 11:24 AM
To: crossgcc@sourceware.cygnus.com
Subject: 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

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



More information about the crossgcc mailing list