0%

问题

Tomcat启动到一半闪退,bin目录下生成了hs_err_pidXXXX.log文件

日志内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1660496 bytes for Chunk::new
# 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 (allocation.cpp:390), pid=6684, tid=0x0000000000000df8
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.201-b09 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Call to MiniDumpWriteDump() failed (Error 0x800705af: 页面文件太小,无法完成操作。

)

翻译过来就是本地内存分配失败, 可能的原因有两种

  1. 系统物理内存或虚拟内存不足
  2. 程序在压缩指针模式下运行, Java堆会阻塞本地堆的增长

解决方案

查看服务器,发现内存足够,尝试按第二个问题进行解决。

禁止使用压缩指针模式,在Catalina.bat中的JAVA_OPTS的值后面加

1
-XX:-UseCompressedOops 

问题

fastjson默认对日期格式序列化,默认是使用时间戳

方案一

1
2
@JSONField (format="yyyy-MM-dd HH:mm:ss")  
public Date birthday;

方案二

1
JSON.toJSONStringWithDateFormat(Object, dateformat, SerializerFeature.WriteDateUseDateFormat)

线上故障主要会包括 CPU、磁盘、内存以及网络问题,而大多数故障可能会包含不止一个层面的问题,所以进行排查时候尽量四个方面依次排查一遍。同时例如 jstack、jmap 等工具也是不囿于一个方面的问题的,基本上出问题就是 df、free、top 三连,然后依次 jstack、jmap 伺候,具体问题具体分析即可。

阅读全文 »

Linux

/etc/my.cnf

Windows

  1. 运行–>services.msc打开服务列表,找到Mysql服务

8YaPhmr2HuqQgkc

  1. 右键选择属性,弹出窗口:

EhpVCFmvDrAYPOT

可以看到在可执行文件的路径是C:\ProgramData\MySQL\MySQL Server 5.7\my.ini,即mysql的配置文件在该目录下。