Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
In this example, the program needs more memory on the heap than is available by default. In a server-class machine running either VM (client or server) with a parallel garbage collector, the default initial and maximum heap sizes are as follows for J2SE 6.0 \[[SunGarbage 06|AA. Java References#SunReferences#Garbage 06]\]:

  • initial heap size: larger of 1/64th of the machine's physical memory on the machine or some reasonable minimum

...

Wiki Markup
The {{OutOfMemoryError}} can be avoided by making sure that there are no infinite loops, memory leaks or unnecessary object retention. If memory requirements are known ahead of time, the heap size in Java can be tailored using the following runtime parameters \[2[[Java 06|AA. Java References#Java 06]\]:

java -Xms<initial heap size> -Xmx<maximum heap size>

...

This rule appears in the C++ Secure Coding Standard as MEM12-CPP. Do not assume infinite heap space.

References

Wiki Markup
\[[SunGarbage 06|AA. Java References#SunReferences#Garbage 06]\] [Garbage Collection Ergonomics|http://java.sun.com/javase/6/docs/technotes/guides/vm/gc-ergonomics.html ], "Default values for the Initial and Maximum heap size"
\[[SunJava 06|AA. Java References#SunReferences#Java 06]\] [Nonjava Standard Options for java: The- the Java application launcher|http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html ], "Syntax for increasing the heap size"
\[[Sun 03|AA. Java References#Sun 03]\] Chapter 5: Tuning the Java Runtime System, [Tuning the Java Heap|http://docs.sun.com/source/817-2180-10/pt_chap5.html#wp57027] 
\[[API 06|AA. Java References#API 06]\] Class ObjectInputStream and ObjectOutputStream
\[[SDN 08|AA. Java References#SDN 08]\] [Serialization FAQ|http://java.sun.com/javase/technologies/core/basic/serializationFAQ.jsp] 
\[[MITRE 09|AA. Java References#MITRE 09]\] [CWE ID 400|http://cwe.mitre.org/data/definitions/400.html] "Uncontrolled Resource Consumption (aka 'Resource Exhaustion')"

...