Skip to content

Commit

Permalink
test: call gc() explicitly to avoid OOM
Browse files Browse the repository at this point in the history
PR-URL: #22301
Refs: nodejs/reliability#12
Refs: #16354
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
  • Loading branch information
refack authored and MylesBorins committed Sep 26, 2018
1 parent f5985c7 commit d58867a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-gc
'use strict';

const common = require('../../common');
Expand Down Expand Up @@ -29,10 +30,13 @@ assert.throws(function() {
buf.toString('latin1');
}, /"toString\(\)" failed/);

// FIXME: Free the memory early to avoid OOM.
// REF: https://github.com/nodejs/reliability/issues/12#issuecomment-412619655
global.gc();
let maxString = buf.toString('latin1', 1);
assert.strictEqual(maxString.length, kStringMaxLength);
// Free the memory early instead of at the end of the next assignment
maxString = undefined;
global.gc();

maxString = buf.toString('latin1', 0, kStringMaxLength);
assert.strictEqual(maxString.length, kStringMaxLength);

0 comments on commit d58867a

Please sign in to comment.