简体   繁体   English

nodejs进程崩溃导致内存不足时如何理解日志

[英]How to understands logs when nodejs process crashes out of memory

My node server crashes with the following logs. 我的节点服务器崩溃,并显示以下日志。

<--- Last few GCs --->

  504158 ms: Mark-sweep 1379.9 (1434.3) -> 1379.0 (1434.3) MB, 1486.7 / 0.0 ms [allocation failure] [GC in old space requested].
  505610 ms: Mark-sweep 1379.0 (1434.3) -> 1379.0 (1434.3) MB, 1452.0 / 0.0 ms [allocation failure] [GC in old space requested].
  507067 ms: Mark-sweep 1379.0 (1434.3) -> 1379.0 (1406.3) MB, 1456.1 / 0.0 ms [last resort gc].
  508505 ms: Mark-sweep 1379.0 (1406.3) -> 1379.0 (1406.3) MB, 1438.3 / 0.0 ms [last resort gc].

I understand Mark-sweep is a GC algorithm. 我了解Mark-sweep是GC算法。 How do we interpret these numbers "1379.9 (1434.3) -> 1379.0 (1434.3) MB, 1486.7 / 0.0 ms" after that? 之后,我们如何解释这些数字“ 1379.9(1434.3)-> 1379.0(1434.3)MB,1486.7 / 0.0 ms”?

These are reported metrics at the end of a GC mark-sweep (go through, mark for removal, then sweep the marked items). 这些是在GC标记扫描结束时报告的指标(检查,标记要删除,然后扫描标记的项目)。 The two numbers are start and end of the total object size and total memory size. 这两个数字是总对象大小和总内存大小的开始和结束。

So at the beginning your total object size is 1379.9 and your total memory size is 1434.4 MB. 因此,一开始您的总对象大小为1379.9,而总内存大小为1434.4 MB。 At the end your total object size is 1379.0 and your total memory size is 1434.3 MB. 最后,您的总对象大小为1379.0,总内存大小为1434.3 MB。 So 0.9 MB was freed. 因此释放了0.9 MB。

I'm not 100% certain about the timings, but I believe the first is the total external time spent (which seems to be total time spent in certain "scopes") 我不确定100%的时间安排,但我相信第一个时间是花费的总外部时间(这似乎是某些“范围”中花费的总时间)

Here's the source code you want: https://github.com/nodejs/node/blob/de732725d8ae232d7b6d56927ea8bef471d5bf1d/deps/v8/src/heap/gc-tracer.cc#L481 这是您想要的源代码: https : //github.com/nodejs/node/blob/de732725d8ae232d7b6d56927ea8bef471d5bf1d/deps/v8/src/heap/gc-tracer.cc#L481

Regarding external time spent: https://github.com/nodejs/node/blob/de732725d8ae232d7b6d56927ea8bef471d5bf1d/deps/v8/src/heap/gc-tracer.h#L368 关于花费的外部时间: https : //github.com/nodejs/node/blob/de732725d8ae232d7b6d56927ea8bef471d5bf1d/deps/v8/src/heap/gc-tracer.h#L368

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM