0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/lib
Ben Noordhuis 570e4be932 zlib: reduce memory consumption, release early
In zlibBuffer(), don't wait for the garbage collector to reclaim the zlib memory
but release it manually. Reduces memory consumption by a factor of 10 or more
with some workloads.

Test case:

  function f() {
    require('zlib').deflate('xxx', g);
  }
  function g() {
    setTimeout(f, 5);
  }
  f();

Observe RSS memory usage with and without this commit. After 10,000 iterations,
RSS stabilizes at ~35 MB with this commit. Without, RSS is over 300 MB and keeps
growing.

Cause: whenever the JS object heap hits the high-water mark, the V8 GC sweeps
it clean, then tries to grow it in order to avoid more sweeps in the near
future. Rule of thumb: the bigger the JS heap, the lazier the GC can be.

A side effect of a bigger heap is that objects now live longer. This is harmless
in general but it affects zlib context objects because those are tied to large
buffers that live outside the JS heap, on the order of 16K per context object.

Ergo, don't wait for the GC to reclaim the memory - it may take a long time.

Fixes #4172.
2012-10-30 15:03:17 +01:00
..
_debugger.js debugger: test repeating last command 2012-09-28 10:58:50 +04:00
_linklist.js
assert.js doc: update assert.doesNotThrow() docs 2012-08-29 02:36:22 +02:00
buffer_ieee754.js
buffer.js buffer: include encoding value in exception when invalid 2012-10-09 16:18:26 +02:00
child_process.js child_process: don't die when disconnect event exists 2012-09-22 03:49:17 +02:00
cluster.js cluster: make 'listening' handler see actual port 2012-10-09 16:23:24 +02:00
console.js console: refactor the console module to be reusable 2012-08-24 14:31:32 -07:00
constants.js
crypto.js crypto: pbkdf2 throws when no callback provided 2012-10-23 10:48:51 -07:00
dgram.js dgram: remove stale code 2012-10-13 01:27:15 +02:00
dns.js Revert "DNS: Support NAPTR queries" 2012-06-16 11:02:49 -07:00
domain.js domain: Remove stray console.log 2012-09-25 11:08:52 -07:00
events.js Merge remote-tracking branch 'ry/v0.8' into v0.8-merge 2012-09-28 09:47:48 -07:00
freelist.js
fs.js string_decoder: Add 'end' method, do base64 properly 2012-10-11 16:46:18 -07:00
http.js lint 2012-10-12 11:46:36 -07:00
https.js https: fix renegotation attack protection 2012-10-09 16:38:00 +02:00
module.js lint 2012-10-12 11:46:36 -07:00
net.js string_decoder: Add 'end' method, do base64 properly 2012-10-11 16:46:18 -07:00
os.js Add --no-deprecation and --trace-deprecation flags 2012-06-21 12:05:33 -07:00
path.js path: add platform specific path delimiter 2012-10-01 22:10:36 +02:00
punycode.js punycode: update to v1.1.1 2012-07-04 13:45:14 +02:00
querystring.js trivial: Doc typo and lint fix 2012-06-19 14:07:48 -07:00
readline.js repl: call resume() after setRawMode() 2012-10-24 02:52:18 +02:00
repl.js Merge remote-tracking branch 'origin/v0.8' 2012-10-13 16:16:56 -07:00
stream.js streams: remove useless line 2012-10-21 22:58:14 +02:00
string_decoder.js string_decoder: Add 'end' method, do base64 properly 2012-10-11 16:46:18 -07:00
sys.js Fix #3577 Un-break require('sys') 2012-06-28 10:14:03 -07:00
timers.js lint 2012-08-27 13:03:30 -07:00
tls.js tls: Provide buffer to Connection.setSession 2012-10-23 10:48:50 -07:00
tty.js Add --no-deprecation and --trace-deprecation flags 2012-06-21 12:05:33 -07:00
url.js Merge remote-tracking branch 'origin/v0.8' 2012-10-25 16:08:58 +02:00
util.js lint 2012-10-12 11:46:36 -07:00
vm.js lint 2012-03-03 23:48:57 -08:00
zlib.js zlib: reduce memory consumption, release early 2012-10-30 15:03:17 +01:00