Java 8 在使用内存爆了以后会发生什么?hs_err_pid 日志如何看?
问题:
Java进程被终止了,然后在应用的目录中发现了hs_err_pid日志。
运维反馈,结论是内存不够了
之前一直运行没有问题,没什么新增访问量,为什么会内存溢出,进程被killer掉类?
1.第一反应看日志:
hs_err_pid,内容如下:
# # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 65536 bytes for committing reserved memory. # Possible reasons: # The system is out of physical RAM or swap space # The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap # Possible solutions: # Reduce memory load on the system # Increase physical memory or swap space # Check if swap backing store is full # Decrease Java heap size (-Xmx/-Xms) # Decrease number of Java threads # Decrease Java thread stack sizes (-Xss) # Set larger code cache with -XX:ReservedCodeCacheSize= # JVM is running with Unscaled Compressed Oops mode in which the Java heap is # placed in the first 4GB address space. The Java Heap base address is the # maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress # to set the Java Heap base and to place the Java Heap above 4GB virtual address. # This output file may be truncated or incomplete. # # Out of Memory Error (os_linux.cpp:2798), pid=15490, tid=0x00007f47859bc700 # # JRE version: OpenJDK Runtime Environment (8.0_262-b10) (build 1.8.0_262-b10) # Java VM: OpenJDK 64-Bit Server VM (25.262-b10 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 (0x00007f47b4196800): JavaThread "C2 CompilerThread0" daemon [_thread_in_vm, id=15500, stack(0x00007f47858bd000,0x00007f47859bd000)] Stack: [0x00007f47858bd000,0x00007f47859bd000], sp=0x00007f47859b85a0, free space=1005k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0xb5718d] VMError::report_and_die()+0x15d V [libjvm.so+0x50675a] report_vm_out_of_memory(char const*, int, unsigned long, VMErrorType, char const*)+0xaa V [libjvm.so+0x93d3f8] os::pd_commit_memory(char*, unsigned long, unsigned long, bool)+0xd8 V [libjvm.so+0x93457e] os::commit_memory(char*, unsigned long, unsigned long, bool)+0x2e V [libjvm.so+0xb53d94] VirtualSpace::expand_by(unsigned long, bool)+0x1b4 V [libjvm.so+0x61d15c] CodeHeap::expand_by(unsigned long)+0x6c V [libjvm.so+0x48e0e6] CodeCache::allocate(int, bool)+0x46 V [libjvm.so+0x4865db] BufferBlob::create(char const*, int)+0x8b V [libjvm.so+0x48b0e1] CodeBuffer::initialize(int, int)+0x21 V [libjvm.so+0x951a62] Compile::init_buffer(unsigned int*)+0x212 V [libjvm.so+0x959201] Compile::Output()+0x351 V [libjvm.so+0x4ae738] Compile::Code_Gen()+0x4e8 V [libjvm.so+0x4b23ce] Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool, bool)+0x116e V [libjvm.so+0x407e88] C2Compiler::compile_method(ciEnv*, ciMethod*, int)+0x1d8 V [libjvm.so+0x4b9cb2] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x8d2 V [libjvm.so+0x4ba980] CompileBroker::compiler_thread_loop()+0x510 V [libjvm.so+0xafe902] JavaThread::thread_main_inner()+0x212 V [libjvm.so+0x93a382] java_start(Thread*)+0xf2 C [libpthread.so.0+0x7ea5] start_thread+0xc5 Current CompileTask: C2:859196826 31212 4 org.hibernate.engine.query.spi.HQLQueryPlan::<init> (382 bytes) --------------- P R O C E S S --------------- Java Threads: ( => current thread )
用jcmd -l 查看JVM 参数如下:
输入:
sudo -u gitlab-runner jcmd 28102 help
VM.native_memory ManagementAgent.stop ManagementAgent.start_local ManagementAgent.start VM.classloader_stats GC.rotate_log Thread.print GC.class_stats GC.class_histogram GC.heap_dump GC.finalizer_info GC.heap_info GC.run_finalization GC.run VM.uptime VM.dynlibs VM.flags VM.system_properties VM.command_line VM.version help
输入:
sudo -u gitlab-runner jcmd 28102 VM.command_line
VM Arguments: jvm_args: -Xms1200m -Xmx1200m java_command: xxx.jar --spring.profiles.active=prod java_class_path (initial): xxxxxx.jar Launcher Type: SUN_STANDARD
而物理机的内存为:
3.8G
现在的疑惑是内存在没什么访问的情况下,究竟为什么会内存爆掉?内存泄漏?
(未完待续)