A Java OutofMemoryError occurs if infinite heap space is assumed, making the program crash. This error can be generated due to the following possible reasons:1.
- A memory leak
...
- An infinite loop
...
- The program requires more memory than is present by default in the heap
...
- Incorrect implementation of common data
...
- structures (such
...
- as hash tables, vectors etc)
Non Non Compliant Code Example 1
This example uses unlimited amount of memory due to which the program can easily exhaust the heap.
...
initial heap size: Larger of 1/64th of the machine's physical memory on the machine or some reasonable minimum.
maximum heap size: Smaller of 1/4th of the physical memory or 1GB
...
java -Xms128m -Xmx512m ShowHeapError
Here we have set the initial initial heap size as 128Mb and the maximum heap size as 512Mb.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FIO37-J | low | probable | high | P2 | L3 |
Automated Detection
...
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website
...
[2] Non Standard Options for java: The Java application launcher Syntax for increasing the heap size
...