panta82
panta82

Reputation: 2721

node.js 0.12.x memory usage

Trying to upgrade my application from node 0.10.x to node 0.12.x family, I was hit with an unpleasant surprise: 0.12 uses about 15%-20% more RAM than 0.10.

Judging by a few threads on io.js issues page, it seems the fault lies with the underlying v8 engine.

Now software update is a difficult proposition to sell to management as it is. Add to that the need to pay for more VPS hardware with few visible benefits, and this becomes a deal breaker for us.

Is there a way to disable whatever new bells & whistles v8 had added that are taking up the additional RAM? Perhaps the touted CPU profiling stuff?

I'm basically looking for a v8 switch that can reduce memory usage to the level comparable to the v8 shipped with node 0.10.

Upvotes: 22

Views: 1930

Answers (2)

Keng
Keng

Reputation: 854

If reverting back the v.10 is an option for you, you can do that very easily using Node Version Manager NVM. Just switch to any version you like on the go and use it, while waiting for a fix for v.12.

Upvotes: 0

Trott
Trott

Reputation: 70055

You can limit the amount of memory your Node.js process uses with the --max-old-space-size flag. Perhaps you can cap the memory at something acceptable and then benchmark your app to see if it performs acceptably.

node --max-old-space-size=512 myScript.js

I believe there are also flags that control garbage collection that might be worth exploring. And this GitHub issue about v8 performance profiling etc. may be worth your time reading as well.

Upvotes: 8

Related Questions