Java运行时环境没有足够的内存来继续。当我运行我的javac时

问题描述 投票:0回答:1

我正在编译Yak的源代码。(来自论文[OSDI '16]:Yak:一个高性能的大数据友好垃圾收集器)Yak基于OpenJDK 1.8,它对GC算法有一些改变。但是,当我使用命令'bash configure'和'make all'构建一个版本j2sdk-image供使用时,我发现存在问题。当我运行'j2sdk-image / bin / javac xxx.java'时,java文件是一个像HelloWorld这样的简单类。但是,我遇到了一个问题:

zmx@ubuntu:~/nju/yak-openjdk8/my_testcases$ ../build/linux-x86_64-normal-server-release/images/j2sdk-image/bin/javac TestMonotask.java 
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 268435472 bytes for Chunk::new
# An error report file with more information is saved as:
# /home/zmx/nju/yak-openjdk8/my_testcases/hs_err_pid40203.log
[thread 139717465741056 also had an error]

我在运行javac时出现内存问题?这太可怕了。错误日志在这里。

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 268435472 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:388), pid=40203, tid=139717464688384
#
# JRE version: OpenJDK Runtime Environment (8.0) (build 1.8.0-internal-zmx_2019_03_27_21_29-b00)
# Java VM: OpenJDK 64-Bit Server VM (25.0-b70 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

---------------  T H R E A D  ---------------

Current thread (0x00007f12940b0800):  JavaThread "C2 CompilerThread1" daemon [_thread_in_native, id=40214, stack(0x00007f1281ca0000,0x00007f1281da1000)]

Stack: [0x00007f1281ca0000,0x00007f1281da1000],  sp=0x00007f1281d9c000,  free space=1008k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xa0fd15]  VMError::report_and_die()+0x165
V  [libjvm.so+0x49084c]  report_vm_out_of_memory(char const*, int, unsigned long, VMErrorType, char const*)+0xac
V  [libjvm.so+0x28b26c]  Chunk::operator new(unsigned long, AllocFailStrategy::AllocFailEnum, unsigned long)+0xec
V  [libjvm.so+0x28c35b]  Arena::Arealloc(void*, unsigned long, unsigned long, AllocFailStrategy::AllocFailEnum)+0x16b
V  [libjvm.so+0x4f292f]  Dict::doubhash()+0x3f
V  [libjvm.so+0x4f30c8]  Dict::Insert(void*, void*, bool)+0x138
V  [libjvm.so+0x9c6d1b]  Type::hashcons()+0xcb
V  [libjvm.so+0x8a3e7c]  PhaseCCP::analyze()+0x1dc
V  [libjvm.so+0x4369f9]  Compile::Optimize()+0x429
V  [libjvm.so+0x4380d3]  Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool, bool)+0x1083
V  [libjvm.so+0x3893c1]  C2Compiler::compile_method(ciEnv*, ciMethod*, int)+0x1a1
V  [libjvm.so+0x442cd5]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x715
V  [libjvm.so+0x444a39]  CompileBroker::compiler_thread_loop()+0x5b9
V  [libjvm.so+0x9b97e7]  JavaThread::thread_main_inner()+0x117
V  [libjvm.so+0x9b9ad9]  JavaThread::run()+0x2a9
V  [libjvm.so+0x853092]  java_start(Thread*)+0xf2


Current CompileTask:
C2:   4938  165       4       java.lang.String::startsWith (72 bytes)


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x00007f12940c0000 JavaThread "Service Thread" daemon [_thread_blocked, id=40216, stack(0x00007f1281a9e000,0x00007f1281b9f000)]
  0x00007f12940b2800 JavaThread "C1 CompilerThread2" daemon [_thread_blocked, id=40215, stack(0x00007f1281b9f000,0x00007f1281ca0000)]
=>0x00007f12940b0800 JavaThread "C2 CompilerThread1" daemon [_thread_in_native, id=40214, stack(0x00007f1281ca0000,0x00007f1281da1000)]
  0x00007f12940ae000 JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=40213, stack(0x00007f1281da1000,0x00007f1281ea2000)]
  0x00007f12940ab800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=40212, stack(0x00007f1281ea2000,0x00007f1281fa3000)]
  0x00007f129407c800 JavaThread "Finalizer" daemon [_thread_blocked, id=40211, stack(0x00007f128242e000,0x00007f128252f000)]
  0x00007f1294078800 JavaThread "Reference Handler" daemon [_thread_blocked, id=40210, stack(0x00007f128252f000,0x00007f1282630000)]
  0x00007f129400a800 JavaThread "main" [_thread_blocked, id=40204, stack(0x00007f129ba36000,0x00007f129bb37000)]

Other Threads:
  0x00007f1294073800 VMThread [stack: 0x00007f1282630000,0x00007f1282731000] [id=40209]

VM state:at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread:  ([mutex/lock_event])
[0x00007f1294006ae0] Threads_lock - owner thread: 0x00007f1294073800

Heap:
 PSYoungGen      total 14336K, used 1086K [0x00000000f0780000, 0x00000000f1900000, 0x0000000100000000)
  eden space 10752K, 10% used [0x00000000f0780000,0x00000000f088fa60,0x00000000f1200000)
  from space 3584K, 0% used [0x00000000f1580000,0x00000000f1580000,0x00000000f1900000)
  to   space 3584K, 0% used [0x00000000f1200000,0x00000000f1200000,0x00000000f1580000)
 ParOldGen       total 9216K, used 6266K [0x00000000d1600000, 0x00000000d1f00000, 0x00000000f0780000)
  object space 9216K, 67% used [0x00000000d1600000,0x00000000d1c1ea00,0x00000000d1f00000)
 Metaspace       used 8213K, capacity 8980K, committed 9344K, reserved 1056768K
  class space    used 997K, capacity 1040K, committed 1152K, reserved 1048576K

Card table byte_map: [0x00007f12986f3000,0x00007f1298869000] byte_map_base: 0x00007f1298068000

Marking Bits: (ParMarkBitMap*) 0x00007f129ae8f580
 Begin Bits: [0x00007f12838b0000, 0x00007f1284458000)
 End Bits:   [0x00007f1284458000, 0x00007f1285000000)

Polling page: 0x00007f129bb52000

CodeCache: size=245760Kb used=2582Kb max_used=2582Kb free=243177Kb
 bounds [0x00007f1285000000, 0x00007f1285290000, 0x00007f1294000000]
 total_blobs=1031 nmethods=726 adapters=216
 compilation: enabled

Compilation events (10 events):
Event: 0.921 Thread 0x00007f12940b2800  748       2       com.sun.tools.javac.code.Scope$1::accepts (2 bytes)
Event: 0.921 Thread 0x00007f12940b2800 nmethod 748 0x00007f1285284bd0 code [0x00007f1285284d20, 0x00007f1285284e70]
Event: 0.921 Thread 0x00007f12940b2800  744       2       com.sun.tools.javac.tree.JCTree$JCExpressionStatement::accept (6 bytes)
Event: 0.921 Thread 0x00007f12940b2800 nmethod 744 0x00007f1285284f10 code [0x00007f1285285080, 0x00007f1285285208]
Event: 0.921 Thread 0x00007f12940b2800  749       2       com.sun.tools.javac.code.Type$JCVoidType::getTag (4 bytes)
Event: 0.921 Thread 0x00007f12940b2800 nmethod 749 0x00007f1285285290 code [0x00007f12852853e0, 0x00007f1285285530]
Event: 0.922 Thread 0x00007f12940b2800  750       2       java.net.URI::access$300 (7 bytes)
Event: 0.922 Thread 0x00007f12940b2800 nmethod 750 0x00007f12852855d0 code [0x00007f1285285720, 0x00007f1285285868]
Event: 0.922 Thread 0x00007f12940b2800  751       2       com.sun.tools.javac.util.ByteBuffer::appendByte (34 bytes)
Event: 0.922 Thread 0x00007f12940b2800 nmethod 751 0x00007f1285285910 code [0x00007f1285285a80, 0x00007f1285285d68]

GC Heap History (10 events):
Event: 0.438 GC heap before
{Heap before GC invocations=7 (full 0):
 PSYoungGen      total 5120K, used 4688K [0x00000000f0780000, 0x00000000f0d80000, 0x0000000100000000)
  eden space 4096K, 100% used [0x00000000f0780000,0x00000000f0b80000,0x00000000f0b80000)
  from space 1024K, 57% used [0x00000000f0c80000,0x00000000f0d14018,0x00000000f0d80000)
  to   space 1024K, 0% used [0x00000000f0b80000,0x00000000f0b80000,0x00000000f0c80000)
 ParOldGen       total 6656K, used 788K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 11% used [0x00000000d1600000,0x00000000d16c5050,0x00000000d1c80000)
 Metaspace       used 6286K, capacity 7596K, committed 7808K, reserved 1056768K
  class space    used 766K, capacity 808K, committed 896K, reserved 1048576K
Event: 0.441 GC heap after
Heap after GC invocations=7 (full 0):
 PSYoungGen      total 5120K, used 736K [0x00000000f0780000, 0x00000000f1180000, 0x0000000100000000)
  eden space 4096K, 0% used [0x00000000f0780000,0x00000000f0780000,0x00000000f0b80000)
  from space 1024K, 71% used [0x00000000f0b80000,0x00000000f0c38010,0x00000000f0c80000)
  to   space 1024K, 0% used [0x00000000f1080000,0x00000000f1080000,0x00000000f1180000)
 ParOldGen       total 6656K, used 1020K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 15% used [0x00000000d1600000,0x00000000d16ff0f8,0x00000000d1c80000)
 Metaspace       used 6286K, capacity 7596K, committed 7808K, reserved 1056768K
  class space    used 766K, capacity 808K, committed 896K, reserved 1048576K
}
Event: 0.546 GC heap before
{Heap before GC invocations=8 (full 0):
 PSYoungGen      total 5120K, used 4832K [0x00000000f0780000, 0x00000000f1180000, 0x0000000100000000)
  eden space 4096K, 100% used [0x00000000f0780000,0x00000000f0b80000,0x00000000f0b80000)
  from space 1024K, 71% used [0x00000000f0b80000,0x00000000f0c38010,0x00000000f0c80000)
  to   space 1024K, 0% used [0x00000000f1080000,0x00000000f1080000,0x00000000f1180000)
 ParOldGen       total 6656K, used 1020K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 15% used [0x00000000d1600000,0x00000000d16ff0f8,0x00000000d1c80000)
 Metaspace       used 7112K, capacity 8052K, committed 8320K, reserved 1056768K
  class space    used 860K, capacity 880K, committed 896K, reserved 1048576K
Event: 0.565 GC heap after
Heap after GC invocations=8 (full 0):
 PSYoungGen      total 7680K, used 1012K [0x00000000f0780000, 0x00000000f1480000, 0x0000000100000000)
  eden space 6656K, 0% used [0x00000000f0780000,0x00000000f0780000,0x00000000f0e00000)
  from space 1024K, 98% used [0x00000000f1080000,0x00000000f117d028,0x00000000f1180000)
  to   space 2560K, 0% used [0x00000000f0e00000,0x00000000f0e00000,0x00000000f1080000)
 ParOldGen       total 6656K, used 3369K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 50% used [0x00000000d1600000,0x00000000d194a438,0x00000000d1c80000)
 Metaspace       used 7112K, capacity 8052K, committed 8320K, reserved 1056768K
  class space    used 860K, capacity 880K, committed 896K, reserved 1048576K
}
Event: 0.646 GC heap before
{Heap before GC invocations=9 (full 0):
 PSYoungGen      total 7680K, used 7668K [0x00000000f0780000, 0x00000000f1480000, 0x0000000100000000)
  eden space 6656K, 100% used [0x00000000f0780000,0x00000000f0e00000,0x00000000f0e00000)
  from space 1024K, 98% used [0x00000000f1080000,0x00000000f117d028,0x00000000f1180000)
  to   space 2560K, 0% used [0x00000000f0e00000,0x00000000f0e00000,0x00000000f1080000)
 ParOldGen       total 6656K, used 3369K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 50% used [0x00000000d1600000,0x00000000d194a438,0x00000000d1c80000)
 Metaspace       used 7197K, capacity 8116K, committed 8320K, reserved 1056768K
  class space    used 868K, capacity 880K, committed 896K, reserved 1048576K
Event: 0.661 GC heap after
Heap after GC invocations=9 (full 0):
 PSYoungGen      total 9216K, used 2551K [0x00000000f0780000, 0x00000000f1900000, 0x0000000100000000)
  eden space 6656K, 0% used [0x00000000f0780000,0x00000000f0780000,0x00000000f0e00000)
  from space 2560K, 99% used [0x00000000f0e00000,0x00000000f107dc80,0x00000000f1080000)
  to   space 3584K, 0% used [0x00000000f1580000,0x00000000f1580000,0x00000000f1900000)
 ParOldGen       total 6656K, used 4681K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 70% used [0x00000000d1600000,0x00000000d1a92438,0x00000000d1c80000)
 Metaspace       used 7197K, capacity 8116K, committed 8320K, reserved 1056768K
  class space    used 868K, capacity 880K, committed 896K, reserved 1048576K
}
Event: 0.827 GC heap before
{Heap before GC invocations=10 (full 0):
 PSYoungGen      total 9216K, used 9207K [0x00000000f0780000, 0x00000000f1900000, 0x0000000100000000)
  eden space 6656K, 100% used [0x00000000f0780000,0x00000000f0e00000,0x00000000f0e00000)
  from space 2560K, 99% used [0x00000000f0e00000,0x00000000f107dc80,0x00000000f1080000)
  to   space 3584K, 0% used [0x00000000f1580000,0x00000000f1580000,0x00000000f1900000)
 ParOldGen       total 6656K, used 4681K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 70% used [0x00000000d1600000,0x00000000d1a92438,0x00000000d1c80000)
 Metaspace       used 8059K, capacity 8884K, committed 8960K, reserved 1056768K
  class space    used 985K, capacity 1008K, committed 1024K, reserved 1048576K
Event: 0.836 GC heap after
Heap after GC invocations=10 (full 0):
 PSYoungGen      total 14336K, used 2615K [0x00000000f0780000, 0x00000000f1900000, 0x0000000100000000)
  eden space 10752K, 0% used [0x00000000f0780000,0x00000000f0780000,0x00000000f1200000)
  from space 3584K, 72% used [0x00000000f1580000,0x00000000f180dc70,0x00000000f1900000)
  to   space 3584K, 0% used [0x00000000f1200000,0x00000000f1200000,0x00000000f1580000)
 ParOldGen       total 6656K, used 5474K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 82% used [0x00000000d1600000,0x00000000d1b58988,0x00000000d1c80000)
 Metaspace       used 8059K, capacity 8884K, committed 8960K, reserved 1056768K
  class space    used 985K, capacity 1008K, committed 1024K, reserved 1048576K
}
Event: 0.836 GC heap before
{Heap before GC invocations=11 (full 1):
 PSYoungGen      total 14336K, used 2615K [0x00000000f0780000, 0x00000000f1900000, 0x0000000100000000)
  eden space 10752K, 0% used [0x00000000f0780000,0x00000000f0780000,0x00000000f1200000)
  from space 3584K, 72% used [0x00000000f1580000,0x00000000f180dc70,0x00000000f1900000)
  to   space 3584K, 0% used [0x00000000f1200000,0x00000000f1200000,0x00000000f1580000)
 ParOldGen       total 6656K, used 5474K [0x00000000d1600000, 0x00000000d1c80000, 0x00000000f0780000)
  object space 6656K, 82% used [0x00000000d1600000,0x00000000d1b58988,0x00000000d1c80000)
 Metaspace       used 8059K, capacity 8884K, committed 8960K, reserved 1056768K
  class space    used 985K, capacity 1008K, committed 1024K, reserved 1048576K
Event: 0.879 GC heap after
Heap after GC invocations=11 (full 1):
 PSYoungGen      total 14336K, used 0K [0x00000000f0780000, 0x00000000f1900000, 0x0000000100000000)
  eden space 10752K, 0% used [0x00000000f0780000,0x00000000f0780000,0x00000000f1200000)
  from space 3584K, 0% used [0x00000000f1580000,0x00000000f1580000,0x00000000f1900000)
  to   space 3584K, 0% used [0x00000000f1200000,0x00000000f1200000,0x00000000f1580000)
 ParOldGen       total 9216K, used 6266K [0x00000000d1600000, 0x00000000d1f00000, 0x00000000f0780000)
  object space 9216K, 67% used [0x00000000d1600000,0x00000000d1c1ea00,0x00000000d1f00000)
 Metaspace       used 8059K, capacity 8884K, committed 8960K, reserved 1056768K
  class space    used 985K, capacity 1008K, committed 1024K, reserved 1048576K
}

Deoptimization events (0 events):
No events

Internal exceptions (10 events):
Event: 0.893 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f07c3ce8) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.894 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f07c8388) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.894 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f07cb698) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.894 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f07ce6f0) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.894 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f07d1850) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.894 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f07d4878) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.918 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f0856618) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.919 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f085af90) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.919 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f085e508) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]
Event: 0.923 Thread 0x00007f129400a800 Exception <a 'java/security/PrivilegedActionException'> (0x00000000f086a198) thrown at [/home/zmx/nju/yak-openjdk8/hotspot/src/share/vm/prims/jvm.cpp, line 1376]


我的Ubuntu上有3g内存。当我运行javac时,我发现内存从600m上升到3g,然后javac(javac !!而不是java)进程被杀死。我想知道问题出在哪里。希望可以有人帮帮我。谢谢!

java jvm javac
1个回答
0
投票

问题是我使用的环境与Yak的作者不同。这是正确的环境。当我使用正确的环境时,问题就解决了。

  • CentOS 6.9
  • 启动JDK:JDK 1.7
  • gcc 5.2或更高版本
© www.soinside.com 2019 - 2024. All rights reserved.