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);