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 <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
  • Loading branch information
refack authored and rvagg committed Aug 15, 2018
1 parent 7223a91 commit 1d15f33
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 1d15f33

Please sign in to comment.