Skip to content

Instantly share code, notes, and snippets.

@timdp
Created March 1, 2017 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timdp/036b9631195479c22c2f56f2367f1a73 to your computer and use it in GitHub Desktop.
Save timdp/036b9631195479c22c2f56f2367f1a73 to your computer and use it in GitHub Desktop.
libxmljs memory leak
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