<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi all,<br>
<br>
I have worked on a solution that deals with out-of-memory-errors
(OOMEs) that can occur in C2<br>
on Solaris. The current patch should give you an idea of the
solution. The final patch will still <br>
need some work.<br>
See below for a more detailed description of the path.<br>
<br>
Many thanks in advance,<br>
Albert<br>
<br>
jbs: <a href="https://jbs.oracle.com/bugs/browse/JDK-8016057">https://jbs.oracle.com/bugs/browse/JDK-8016057</a><br>
webrev: <a
href="http://cr.openjdk.java.net/%7Eanoll/8016057/webrev.00/">http://cr.openjdk.java.net/~anoll/8016057/webrev.00/</a><br>
<br>
The current approach aims at avoiding OOMEs using two approaches:<br>
<br>
1) Pre-allocate memory in arenas used by C2<br>
Preallocation happens at two layers:<br>
a) Arenas<br>
Arenas used by C2 preallocate memory. If "normal" memory
allocation fails then (i) C2 is asked<br>
to stop compilation (ii) the preallocated memory is used to
continue execution until the next if<br>
(failing()) call, which provides a safe path to abort compilation.
In the current patch, the size of <br>
preallocated memory is 10% of the size of the arena. This strategy
works well for the reported<br>
problem.<br>
b) Chunk pool<br>
Each chunk pool preallocates one chunk that can be used as a
backup.<br>
<br>
This two-layer memory preallocation avoids frequent preallocations
of small (<32K) chunks in arenas.<br>
<br>
2) Change code in C2 to check for NULL pointers when no memory is
available<br>
Where easily possible, memory allocation are changed so that they
return NULL. Checks against NULL are introduced. <br>
<br>
Discussion and alternative solutions:<br>
This patch does not completely solve OOMEs in C2. It rather reduces
the chance of crashing. I.e., C2 can still crash if the preallocated
memory is not sufficient to reach the next if (failing()) check.
Another disadvantage is that C2 consumes additional memory that is
not used in most cases.<br>
<br>
A clean solution would require to check all memory allocations in C2
against NULL and provide a safe bailout path. I think that this is a
major change to C2 that should be discussed in detail.<br>
<br>
<br>
I want to thank Niclas, Roland, Markus, Vladimir, and John for the
discussions.<br>
<br>
Best,<br>
Albert<br>
</body>
</html>