JDK-8011661 : Insufficient memory message says "malloc" when sometimes it should say "mmap"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs25
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-04-05
  • Updated: 2014-06-26
  • Resolved: 2013-04-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8Fixed hs25Fixed
Related Reports
Relates :  
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1048576 bytes for Allocator failed to commit

I admit that this message is not perfect. First it says "(malloc)" even though it was actually mmap that failed. But this is I think more of a bug in vm_exit_out_of_memory() than in my use of it. There are several places that use VirtualSpace and when it fails call vm_exit_out_of_memory(). This has the same issue as my code. For example when we try to expand the heap in G1 with G1CollectedHeap::expand()

The function vm_exit_out_of_memory() should pass a flag and print information whether it fails because of malloc or mmap.

A fix is adding an enum parameter to the vm_exit_out_of_memory macro and the report_vm_out_of_memory function so that the caller can indicate whether it's a malloc or mmap error. Main changes are in debug.[cpp | hpp] and vmError.[cpp | hpp]. Other changes are mainly for passing in the additional enum when calling vm_exit_out_of_memory.