insufficient memory for the Java Runtime Environment to continue though RAM is showing 6 GB free space

44,081

Solution 1

I was getting the similar memory dumps while running the same java application on Windows 10 and 8.1(both 64 bit).

Windows 8.1

32GB RAM

i7-4790 3.60GHz CPU

Paging file size(fixed, 14GB)

Windows 10

16GB RAM

i7-4790 3.60GHz CPU

Paging file size(automatically managed, initially was fixed, 14GB)

1st issue was that with identical hardware(the difference in RAM only and OS), application on Windwos 10 was crashing almost instantly. The most surprising thing, that in Task manager I saw that only 25% of RAM is used.

After searching info in google, I've found that:

  1. I need to set automatically managed paging file for Windows 10.
  2. Windows 10 is more greedy with committed memory than previous versions of windows.

2nd issue

As was mentioned by @borjab

Java, by default, does not uses all available memory.

To get a help on non-standard options for Java type in your CMD:

java -X

Output:

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size

<size> can be defined in

G - Gigabytes  
M - Megabytes  
K - Kilobytes

The final solution for both OS was:

java -Xmx15G -Xms15G -jar selenium-server-standalone-3.4.0.jar

My initial java version

java version "1.8.0_91"

Java(TM) SE Runtime Environment (build 1.8.0_91-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Updated java version

java version "1.8.0_152"

Java(TM) SE Runtime Environment (build 1.8.0_152-b16)

Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

Solution 2

Java, by default, does not uses all avalaible memory. You need to run the application with the corresponding parameters.

See this question to all the details. (It can change with the version of Java).

The parameter setting can be set on the command line but if you use an application you may have some configuration file. For example, in Eclipse you have eclipse.ini where you an set your memory preferences.

Solution 3

Your application, by default, does not use all the available system memory (or RAM). The limit depends on the xmx value you have set.

Not sure if 64 bit is an option for you, if it is, this lets you increase your xmx more than the 32 bit version.

Solution 4

Some programs use a lot of memory, like Elasticsearch, try to add more memory if you use this kind of memory intensive program

Share:
44,081
user3305063
Author by

user3305063

Updated on July 18, 2022

Comments

  • user3305063
    user3305063 almost 2 years

    While running java application I'm getting the following memory dump.

    After installing java 8(with java 7 application was working before) I started getting the below error.

    I'm using 16 GB RAM and in task manager when I checked (while application was starting)around 6 GB RAM was free.

    Could some one please help what could be the issue?

    #
    # There is insufficient memory for the Java Runtime Environment to continue.
    # Native memory allocation (malloc) failed to allocate 472736 bytes for Chunk::new
    # Possible reasons:
    #   The system is out of physical RAM or swap space
    #   In 32 bit mode, the process size limit was hit
    # Possible solutions:
    #   Reduce memory load on the system
    #   Increase physical memory or swap space
    #   Check if swap backing store is full
    #   Use 64 bit Java on a 64 bit OS
    #   Decrease Java heap size (-Xmx/-Xms)
    #   Decrease number of Java threads
    #   Decrease Java thread stack sizes (-Xss)
    #   Set larger code cache with -XX:ReservedCodeCacheSize=
    # This output file may be truncated or incomplete.
    #
    #  Out of Memory Error (allocation.cpp:390), pid=1104, tid=0x00000000000016ec
    #
    # JRE version: Java(TM) SE Runtime Environment (8.0_92-b14) (build 1.8.0_92-b14)
    # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.92-b14 mixed mode windows-amd64 compressed oops)
    # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
    #
    
    ---------------  T H R E A D  ---------------
    
    ---------------------------------------------------
    
    Java Threads: ( => current thread )
      0x00000000232a8800 JavaThread "AWSessionMonitor Thread" daemon [_thread_blocked, id=14084, stack(0x0000000022b20000,0x0000000022c20000)]
      0x0000000028728800 JavaThread "Thread-3" [_thread_blocked, id=11332, stack(0x00000000210b0000,0x00000000211b0000)]
      0x00000000252a4800 JavaThread "Thread-2" [_thread_blocked, id=5272, stack(0x0000000020fb0000,0x00000000210b0000)]
      0x000000001e874000 JavaThread "SQLStatementMonitor" [_thread_blocked, id=1876, stack(0x0000000022620000,0x0000000022720000)]
      0x000000001de0d800 JavaThread "Thread-1" daemon [_thread_blocked, id=13052, stack(0x0000000022520000,0x0000000022620000)]
      0x000000001f7f8000 JavaThread "Session Timeout Thread" daemon [_thread_blocked, id=11088, stack(0x0000000022220000,0x0000000022320000)]
      0x0000000002c11800 JavaThread "DestroyJavaVM" [_thread_blocked, id=14168, stack(0x0000000002a00000,0x0000000002b00000)]
      0x000000001f32b800 JavaThread "Thread-0" [_thread_in_vm, id=10720, stack(0x0000000020bc0000,0x0000000020cc0000)]
      0x000000001fb3e800 JavaThread "Perf_Log_Traceplan-" daemon [_thread_blocked, id=2992, stack(0x0000000020ac0000,0x0000000020bc0000)]
      0x0000000020319800 JavaThread "Perf_Log_Traceperf-" daemon [_thread_blocked, id=6176, stack(0x00000000209c0000,0x0000000020ac0000)]
      0x000000001da8b000 JavaThread "Service Thread" daemon [_thread_blocked, id=9968, stack(0x000000001e020000,0x000000001e120000)]
      0x000000001da64000 JavaThread "C1 CompilerThread2" daemon [_thread_blocked, id=12708, stack(0x000000001df20000,0x000000001e020000)]
      0x000000001c13e000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=10652, stack(0x000000001de20000,0x000000001df20000)]
    =>0x000000001c128000 JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=5868, stack(0x000000001d920000,0x000000001da20000)]
      0x000000001c118000 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=12444, stack(0x000000001d820000,0x000000001d920000)]
      0x000000001c10c000 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_in_native, id=2640, stack(0x000000001d720000,0x000000001d820000)]
      0x000000001c100800 JavaThread "Attach Listener" daemon [_thread_blocked, id=9952, stack(0x000000001d620000,0x000000001d720000)]
      0x000000001c0ff800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=13880, stack(0x000000001d520000,0x000000001d620000)]
      0x000000001c0e6000 JavaThread "Finalizer" daemon [_thread_blocked, id=7868, stack(0x000000001d340000,0x000000001d440000)]
      0x000000001c0bd000 JavaThread "Reference Handler" daemon [_thread_blocked, id=11580, stack(0x000000001d240000,0x000000001d340000)]
    
    Other Threads:
      0x000000001c0b3800 VMThread [stack: 0x000000001d140000,0x000000001d240000] [id=12984]
      0x000000001db42800 WatcherThread [stack: 0x000000001e120000,0x000000001e220000] [id=9136]
    
    VM state:not at safepoint (normal execution)
    
    VM Mutex/Monitor currently owned by a thread: None
    
    Heap:
     PSYoungGen      total 524800K, used 42318K [0x000000076c580000, 0x000000078cf80000, 0x00000007c0000000)
      eden space 515584K, 8% used [0x000000076c580000,0x000000076eed3b10,0x000000078bd00000)
      from space 9216K, 0% used [0x000000078bd00000,0x000000078bd00000,0x000000078c600000)
      to   space 8704K, 0% used [0x000000078c600000,0x000000078c600000,0x000000078ce80000)
     ParOldGen       total 99328K, used 24647K [0x00000006c5000000, 0x00000006cb100000, 0x000000076c580000)
      object space 99328K, 24% used [0x00000006c5000000,0x00000006c6811d80,0x00000006cb100000)
     Metaspace       used 22833K, capacity 23012K, committed 23344K, reserved 1071104K
      class space    used 2715K, capacity 2786K, committed 2864K, reserved 1048576K
    
    Card table byte_map: [0x00000000120c0000,0x00000000128a0000] byte_map_base: 0x000000000ea98000
    
    Marking Bits: (ParMarkBitMap*) 0x0000000069bf64f0
     Begin Bits: [0x00000000131e0000, 0x00000000170a0000)
     End Bits:   [0x00000000170a0000, 0x000000001af60000)
    
    Polling page: 0x00000000024b0000
    
    CodeCache: size=245760Kb used=11544Kb max_used=11559Kb free=234215Kb
     bounds [0x0000000002d00000, 0x0000000003860000, 0x0000000011d00000]
     total_blobs=2659 nmethods=2233 adapters=346
     compilation: enabled
    
    Compilation events (10 events):
    Event: 191.393 Thread 0x000000001da64000 2532       3       org.apache.xerces.util.XMLAttributesImpl::checkDuplicatesNS (278 bytes)
    Event: 191.393 Thread 0x000000001c13e000 2535       4       org.apache.xerces.impl.XMLEntityScanner::scanQName (510 bytes)
    Event: 191.394 Thread 0x000000001da64000 nmethod 2532 0x0000000003825d10 code [0x0000000003825f60, 0x0000000003826d38]
    Event: 191.394 Thread 0x000000001da64000 2530       3       org.apache.xerces.impl.xs.opti.SchemaDOM::emptyElement (23 bytes)
    Event: 191.394 Thread 0x000000001da64000 nmethod 2530 0x00000000037d66d0 code [0x00000000037d6840, 0x00000000037d6a98]
    Event: 191.394 Thread 0x000000001da64000 2533       3       org.apache.xerces.impl.xs.opti.SchemaDOM::startElement (29 bytes)
    Event: 191.395 Thread 0x000000001da64000 nmethod 2533 0x00000000037fb4d0 code [0x00000000037fb640, 0x00000000037fb8b8]
    Event: 191.395 Thread 0x000000001da64000 2534       3       org.apache.xerces.impl.xs.opti.SchemaDOM::endElement (30 bytes)
    Event: 191.395 Thread 0x000000001da64000 nmethod 2534 0x0000000003825750 code [0x00000000038258c0, 0x0000000003825b90]
    Event: 191.423 Thread 0x000000001c13e000 nmethod 2535 0x000000000384fe10 code [0x0000000003850000, 0x0000000003850fe0]
    
    
    ---------------  S Y S T E M  ---------------
    
    OS: Windows 8.1 , 64 bit Build 9600 (6.3.9600.17415)
    
    CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 58 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, aes, clmul, erms, ht, tsc, tscinvbit, tscinv
    
    Memory: 4k page, physical 16442864k(1810952k free), swap 19025808k(6260k free)
    
    vm_info: Java HotSpot(TM) 64-Bit Server VM (25.92-b14) for windows-amd64 JRE (1.8.0_92-b14), built on Mar 31 2016 21:03:04 by "java_re" with MS VC++ 10.0 (VS2010)
    
    time: Mon May 23 12:38:20 2016
    elapsed time: 191 seconds (0d 0h 3m 11s)
    
  • Nash N
    Nash N over 4 years
    If down voted, please share your reason that helps me and the community. I find no reason why this should be downvoted.