11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Flags: --expose-gc --no-concurrent-array-buffer-sweeping 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst zlib = require('zlib'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Tests that native zlib handles start out their life as weak handles. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciglobal.gc(); 101cb0ef41Sopenharmony_ciconst before = process.memoryUsage().external; 111cb0ef41Sopenharmony_cifor (let i = 0; i < 100; ++i) 121cb0ef41Sopenharmony_ci zlib.createGzip(); 131cb0ef41Sopenharmony_ciconst afterCreation = process.memoryUsage().external; 141cb0ef41Sopenharmony_ciglobal.gc(); 151cb0ef41Sopenharmony_ciconst afterGC = process.memoryUsage().external; 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciassert((afterGC - before) / (afterCreation - before) <= 0.05, 181cb0ef41Sopenharmony_ci `Expected after-GC delta ${afterGC - before} to be less than 5 %` + 191cb0ef41Sopenharmony_ci ` of before-GC delta ${afterCreation - before}`); 20