node.js - nodejs decrease v8 garbage collector memory usage -
i'm debugging nodejs application util module , while heapused value stays around 30-100mb, heaptotal value grows 1.4gb.
here question similar behaviour
i've read way how v8 garbage collector behaves, question how decrease amount of memory allocates (make less 1.4gb) if running on 512 mb device example
you need control max memory size flags (all sizes taken in mb).
the recommended amounts "low memory device" are:
node --max-executable-size=96 --max-old-space-size=128 --max-semi-space-size=1 app.js
for 32-bit and/or android and
node --max-executable-size=192 --max-old-space-size=256 --max-semi-space-size=2 app.js
for 64-bit non-android.
these limit heap totals 225mb , 450mb respectively. doesn't include memory usage outside js. instance buffers allocated "c memory" , not in javascript heap.
also should know closer heap limit more time wasted in gc. e.g. if @ 95% memory usage 90% of cpu used gc , 10% running actual code (not real numbers give general idea). should generous possible limits , never exceed 16% of maximum memory usage (i.e. heapused/limit
should not greater 0.16
). 16% recall paper, might not optimal.
flags:
--max-executable-size
maximum size of heap reserved executable code (the native code result of just-in-time compiled javascript).--max-old-space-size
maximum size of heap reserved long term objects--max-semi-space-size
maximum size of heap reserved short term objects
Comments
Post a Comment