-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: fix memory leak for v8.serialize
When Buffer::New passes in existing data, it cannot be garbage collected in js synchronous execution. Fixes: #40828 Refs: #38300 PR-URL: #42695 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
- Loading branch information
1 parent
f00f183
commit 3c1d169
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
// Flags: --expose-gc | ||
|
||
require('../common'); | ||
const v8 = require('v8'); | ||
const assert = require('assert'); | ||
|
||
const before = process.memoryUsage.rss(); | ||
|
||
for (let i = 0; i < 1000000; i++) { | ||
v8.serialize(''); | ||
} | ||
|
||
global.gc(); | ||
|
||
const after = process.memoryUsage.rss(); | ||
|
||
if (process.config.variables.asan) { | ||
assert(after < before * 10, `asan: before=${before} after=${after}`); | ||
} else { | ||
assert(after < before * 2, `before=${before} after=${after}`); | ||
} |