Problem when heap is exhausted

e.fraga at e.fraga at
Tue Apr 22 03:12:30 PDT 1997

I run fairly large applications written in Java and frequently run out
of heap space. This is not a problem per se (it's easy enough to re-run
with a larger heap) but when using kaffe (version 0.8.4), this leads to
a segmentation fault which is a little annoying.

I've tracked the problem down somewhat. The problem is in this snippet
of code in gc-malloc.c (around line 290):

 	op = (union overhead *)gcheap_sbrk(amt);
	/* no more room! */
  	if ((int)op == -1)
	 * Add new memory allocated to that on
	 * free list for this hash bucket.
  	nextf[bucket] = op;
  	while (--nblks > 0) {
		op->ov_next = (union overhead *)((caddr_t)op + sz);
		op = (union overhead *)((caddr_t)op + sz);

Unfortunately, when no heap space is left, the function GCHEAP_SBRK()
does not return -1 but NULL (according to gdb) and hence the check
immediately after the call does not test true.  I've not checked any
further unfortunately.

Eric S Fraga, Chem & Biochem Eng, UCL.

More information about the kaffe mailing list