From 1d15f332772d257b4124eeedd25be8f3a39cc543 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 13 Aug 2018 16:18:40 -0400 Subject: [PATCH] test: call gc() explicitly to avoid OOM PR-URL: https://github.com/nodejs/node/pull/22301 Refs: https://github.com/nodejs/reliability/issues/12 Refs: https://github.com/nodejs/node/issues/16354 Reviewed-By: Rich Trott Reviewed-By: Ruben Bridgewater Reviewed-By: Joyee Cheung Reviewed-By: Gus Caplan --- .../test-stringbytes-external-exceed-max-by-1-binary.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js index f8aed7c0b2e09b..e4edd32797c2af 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js @@ -1,3 +1,4 @@ +// Flags: --expose-gc 'use strict'; const common = require('../../common'); @@ -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);