# 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.