Created
March 1, 2017 23:42
-
-
Save timdp/036b9631195479c22c2f56f2367f1a73 to your computer and use it in GitHub Desktop.
libxmljs memory leak
This file contains hidden or 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
const libxmljs = require('libxmljs') | |
const doc = new libxmljs.Document() | |
const measure = () => { | |
global.gc() | |
return process.memoryUsage() | |
} | |
const run = () => { | |
const el = new libxmljs.Element(doc, 'Node') | |
el.text('foobarbaz') | |
el.text('') | |
} | |
console.time('warmup') | |
for (let i = 0; i < 2000000; ++i) { | |
run() | |
} | |
console.timeEnd('warmup') | |
const before = measure() | |
console.log('before:', before) | |
for (let i = 0; i < 2000000; ++i) { | |
run() | |
} | |
const after = measure() | |
console.log('after: ', after) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment