Problem when heap is exhausted

e.fraga at ucl.ac.uk e.fraga at ucl.ac.uk
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)
  		return;
	/*
	 * 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.

Thanks,
eric
-- 
........oo...ooo..o..o.o...o.o....oooo..oo...o.....o.....ooo..o..............
Eric S Fraga, Chem & Biochem Eng, UCL. http://minerva.chemeng.ucl.ac.uk/eric/



More information about the kaffe mailing list