看了一下关于 node 内存限制的资料,发现众说不一,朴灵的《深入浅出 NodeJS》说道可以通过 --max-old-space-size 和 --max-new-space-size 来设置 v8 使用内存的上限。官方 git 微博上说道:
Currently, by default v8 has a memory limit of 512mb on 32-bit systems, and 1gb on 64-bit systems. The limit can be raised by setting --max-old-space-size to a maximum of ~1gb (32-bit) and ~1.7gb (64-bit), but it is recommended that you split your single process into several workers if you are hitting memory limits.
设置以后最大上限为 1G 和 1.7G。
后来自己测试了一下,貌似最大上限 64 位也就是 1.7G 左右。请问有没有什么办法可以设置内存使用上限的?
两年前的贴... http://cnodejs.org/topic/500904be4764b72902d30f4d
贴这个link 可能跑题了...不过可能是需要用到大内存的一个场景吧...
Raw data is stored in instances of the Buffer class. A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap.