From d58867a6a7c9376fcbfecd94f96d36af3c787f74 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 996c01752da7c6..844ebb45bac612 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'); @@ -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);