Node.js和V8垃圾收集 [英] Node.js and V8 garbage collection

查看:97
本文介绍了Node.js和V8垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我目前阅读的内容,如果我错了,请纠正我的错误:


  1. Node.js基于V8 JavaScript引擎。

  2. V8 JavaScript引擎实现停止世界的垃圾收集。

。使Node.js有时完全关闭几秒到几分钟来处理垃圾回收。



如果这是针对生产代码运行的,那么几秒钟10,000用户。



在生产环境中,这是否真的可以接受?

解决方案

是否可以接受取决于您的应用程序和您的堆大小。 Big Gc大约是1.3MB每兆字节。因人而异。约一半的压缩气相色谱。 10个左右的GC大。 3个左右的大型气相色谱仪正在紧缩。使用V8标志--trace-gc来记录GC。我们已经做了一些减少停顿的工作。没有承诺,没有时间表。请参阅V8回购中的branches / experimental / gc。

Here's what's I've read so far, and correct me if I'm wrong:

  1. Node.js is based on V8 JavaScript engine.
  2. V8 JavaScript engine implements stop-the-world garbage collection

Which..causes Node.js to sometimes completely shutdown for a few seconds to a few minutes to handle garbage collection.

If this is running for production code, that's a few seconds for 10,000 users.

Is this really acceptable in production environment?

解决方案

Whether it is acceptable depends on your application and your heap size. Big Gc is around 1.3ms per Mbyte. YMMV. About half that for a compacting GC. Around 1 GC in 10 is big. Around 1 big GC in 3 is compacting. Use V8 flag --trace-gc to log GCs. We have done some work on reducing pauses. No promises, no timetables. See branches/experimental/gc in V8 repo.

这篇关于Node.js和V8垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆