Name: gm110360 Date: 09/25/2002
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Here is a stack trace from an OutOfMemoryError.
<<no stack trace available>>
EXPECTED VERSUS ACTUAL BEHAVIOR :
It should have the trace because trace is 1-line deep,
there is not a large memory requirement for that.
A way to do that is to allocate memory for say a 1024
bytes stack trace in case of memory error. Also developers
dont understand why sometimes the stack trace gets printed
and sometimes not in case of an OutOfMemory error.
I dont understand myself why such an error is so fatal, if
memory gets low, and the user tries to allocate a new byte
, the system should check before trying to allocate if
memory is sufficient (I guess it does that) and then throw
an Error. In that case, the system should reserve some
memory (from the startup of VM) for stack trace.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test
private static final int RATIO = 20;
public static void main(String args)
List list = new ArrayList();
}catch (Throwable thr)
private static void recurse(List list)
private static void iterate(List list)
long free = Runtime.getRuntime().freeMemory();
int newSize = (int)free/RATIO;
byte bytes = new byte[newSize];
You can try to iterate or recurse. If the RATIO is set correctly, you will get
an exception without trace:
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Put debug statements around the code to locate where the
code failed. Hard to do for code that is provided as
(Review ID: 164948)