nodejs-mozilla/test/parallel/test-zlib-unused-weak.js

19 lines
604 B
JavaScript

'use strict';
// Flags: --expose-gc
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}`);