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 rvagg committed Aug 15, 2018
1 parent a562729 commit 9feee1f
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 @@ -35,10 +36,13 @@ common.expectsError(function() {
type: Error
});

// 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 9feee1f

Please sign in to comment.