node/test/parallel/test-zlib-unused-weak.js
Matheus Marchini aa01fcae49
test: fix test-zlib-unused-weak on V8 8.2
Ref: https://chromium-review.googlesource.com/c/v8/v8/+/1997438
Ref: https://chromium-review.googlesource.com/c/v8/v8/+/2010107
Ref: https://github.com/nodejs/node-v8/issues/144
Signed-off-by: Matheus Marchini <mmarchini@netflix.com>

PR-URL: https://github.com/nodejs/node/pull/32831
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-05-12 16:14:14 +02:00

19 lines
642 B
JavaScript

'use strict';
// Flags: --expose-gc --no-concurrent-array-buffer-sweeping
require('../common');
const assert = require('assert');
const zlib = require('zlib');
// Tests that native zlib handles start out their life as weak handles.
const before = process.memoryUsage().external;
for (let i = 0; i < 100; ++i)
zlib.createGzip();
const afterCreation = process.memoryUsage().external;
global.gc();
const afterGC = process.memoryUsage().external;
assert((afterGC - before) / (afterCreation - before) <= 0.05,
`Expected after-GC delta ${afterGC - before} to be less than 5 %` +
` of before-GC delta ${afterCreation - before}`);