recommended V8 GC settings for nodejs in heroku (hitting heroku memory limits)

464 views
Skip to first unread message

spollack

unread,
Jul 24, 2012, 2:52:14 PM7/24/12
to v8-u...@googlegroups.com
I am running a nodejs app in heroku, and on certain datasets i'm going over the heroku memory limit of 512MB. I'm running node v0.6.6 with defaults. I can see via node's process.memoryUsage() that my RSS value does indeed go as high as 544MB on my test dataset, and ps shows similar results. 

What V8 GC settings would you recommend in order to keep the RSS lower? 

Are there any known memory behavior improvements of moving to node v0.6.20 or v0.8.3 that would help me here?

As an aside, running the same test locally (same node version, same code, same data) only hits a max RSS of 155MB, almost a factor of 4 different. Both are x86_64 machines, although my local machine is OSX Lion (11.4.0 Darwin Kernel Version 11.4.0: Mon Apr 9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64) while heroku is Linux 2.6 (2.6.32-343-ec2 #45+lp929941v1 SMP Tue Feb 21 14:07:44 UTC 2012 x86_64 GNU/Linux). Any ideas why that is? 

Thanks.

Vyacheslav Egorov

unread,
Jul 24, 2012, 3:09:25 PM7/24/12
to v8-u...@googlegroups.com
What is V8 heap usage: heapTotal and heapUsed parts reported by
process.memoryUsage?

--
Vyacheslav Egorov
> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users

spollack

unread,
Jul 24, 2012, 3:42:33 PM7/24/12
to v8-u...@googlegroups.com
Thanks for the quick reply. 

Near (but not quite at) the peak, process.memoryUsage reports:
{"rss":537001984,"heapTotal":470088448,"heapUsed":450764712}

Seth
Message has been deleted

spollack

unread,
Jul 24, 2012, 3:52:37 PM7/24/12
to v8-u...@googlegroups.com
here is a reading even closer to the peak: {"rss":542273536,"heapTotal":523510848,"heapUsed":503801408}. lots of heap usage!

as another aside: sometimes i get surprising results for rss, where rss is considerably smaller than heapTotal/heapUsed in the middle of the run, and then it quickly returns to what i would expect (rss > heapTotal > heapUsed). For example, this reading from mid-run: {"rss":345870336,"heapTotal":516328896,"heapUsed":511765976}  Why would that be? is the heap getting swapped out? 

Vyacheslav Egorov

unread,
Jul 25, 2012, 3:18:40 PM7/25/12
to v8-u...@googlegroups.com
Yes, I suspect your heap is being paged out.

I don't know though why your app behaves so differently on different
machines. I suspect there is something in your/node.js/node packages
code that is OS specific and causes larger memory consumption (e.g.
it's buffering too much things in the memory because writing stuff to
network/disk does not keep up with incomming data etc).

I don't think any GC tweaks will be helpful here.

--
Vyacheslav Egorov

spollack

unread,
Jul 25, 2012, 5:15:40 PM7/25/12
to v8-u...@googlegroups.com
I think you are probably right. after more testing, i can see that the GC is running, it just isn't freeing up very much. i probably am accidentally keeping references to state that i don't need. Are there any good tools to help identify what specifically might be getting held onto here? 

Thanks,
Seth

Vyacheslav Egorov

unread,
Jul 25, 2012, 5:47:37 PM7/25/12
to v8-u...@googlegroups.com

You need to use something that gives you access to heap snapshots. I think node-inspector does. But better ask at node.js list.

Vyacheslav Egorov

--
Reply all
Reply to author
Forward
0 new messages