问题解决
在开发的过程中,遇到的一些常用问题解决方案
记录一次内存溢出的问题
背景
线上项目突然挂掉了,控制台打印错误日志如下:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fef90eea05c, pid=23381, tid=140663185188608
#
# JRE version: OpenJDK Runtime Environment (8.0_41-b04) (build 1.8.0_41-b04)
# Java VM: OpenJDK 64-Bit Server VM (25.40-b25 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x68f05c] jni_GetObjectField+0xbc
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/project/word-template/hs_err_pid23381.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
查看详细的错误文件hs_err_pid23381.log
栈帧打印的错误如下:
Stack: [0x00007feeb31fa000,0x00007feeb32fb000], sp=0x00007feeb32f9550, free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x68f05c] jni_GetObjectField+0xbc
C [libfontmanager.so+0x40fa0] CloseTTFontFileFunc+0x50
C [libfreetype.so.6+0x1cad7] FT_Stream_Free+0x17
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.font.FreetypeFontScaler.disposeNativeScaler(Lsun/font/Font2D;J)V+0
j sun.font.FreetypeFontScaler.dispose()V+24
j sun.java2d.Disposer.run()V+26
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
执行命令
jmap -histo <pid> | grep FreetypeFontScaler
显示结果
157: 427 13664 sun.font.FreetypeFontScaler
错误原因:
JDK-8209113:对创建的字体使用最后字体攻击的弱引用
解决方案:
java -jar -Dsun.java2d.font.reftype=weak app.jar
或者升级jdk