BZ #25: Cacao dies if not enough virtual memory to create thread

Status fields:

creation_ts:2006-05-21 03:14
I (foolishly ;) ) enabled strict overcommit handling in my kernel. This means
that attempts to allocate more memory than is physically available in swap+(x%
of RAM, where x defaults to 50) will fail.

Shortly after, eclipse crashed when trying to create a new thread, when I tried
to save my work:

LOG: [0xc71540] pthread_create failed
cacao: threads.c:842: threads_start_thread: Assertion `0' failed.

Clearly then, the pthread_create call could not allocate enough memory for the
new thread.

I suggest that cacao, if it gets EAGAIN from pthread_create, should do
System.gc(), compact memory if necessary, free some virtual memory back to the
kernel, and then try again.

If it fails a second time... well then the VM is truly in trouble, because what
happens in this case is undocumented. But it should at least try to garbage
collect and free, in my opinion.

Comment #1 by on 2006-11-01 00:02:16

Hmm, I actually never replied.  Sorry.  But, pthread_create uses memory from the
system heap, not the Java heap.  That means, if we are out of system memory, can
are really in trouble and can't do anything.  A Java heap collection does not
change anything.

But we now use vm_abort to abort the VM, which prints an error message.  Maybe
that helps.