Memory leak
- Dominant language
- JavaScript
- Stars
- 419
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
I tried to execute the following code, and observe the potential memory leak due to the decompress operation.
`
"use strict";
let path = require("path");
const decompress = require('decompress')
let fs = require("fs");
const used = process.memoryUsage();
for (let key in used) {
console.log(`Memory: ${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
}
let source = path.join(__dirname + "/example.zip");
let output = path.join(__dirname,"output")
decompress("./example.zip", "dist").then((files) => {
console.log("decompress completed")
console.log("-------------------------------")
const used = process.memoryUsage();
for (let key in used) {
console.log(`Memory: ${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
}
global.gc();
console.log("after garbage collection")
process.nextTick(function () {
console.log("after tick")
const used = process.memoryUsage();
for (let key in used) {
console.log(`Memory: ${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
}
});
setTimeout(function () {
console.log("after timeout")
const used = process.memoryUsage();
for (let key in used) {
console.log(`Memory: ${key} ${Math.round(used[key] / 1024 / 1024 * 100) / 100} MB`);
}
}, 5000);
})
`
node --expose-gc decompress.js
Memory: rss 25 MB
Memory: heapTotal 12.73 MB
Memory: heapUsed 6.64 MB
Memory: external 0.09 MB
decompress completed
-------------------------------
Memory: rss 4275.02 MB
Memory: heapTotal 12.23 MB
Memory: heapUsed 5.39 MB
Memory: external 3515.56 MB
after garbage collection
after tick
Memory: rss 1764.59 MB
Memory: heapTotal 12.23 MB
Memory: heapUsed 5.38 MB
Memory: external 1732.47 MB
after timeout
Memory: rss 1764.61 MB
Memory: heapTotal 12.23 MB
Memory: heapUsed 5.39 MB
Memory: external 1732.47 MB
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided decompress.js reproduction with Node.js and --expose-gc, then inspect the decompress operation and its memory measurements. Confirm whether the reported external memory remains after garbage collection and the timeout; done means the reproduction no longer shows the reported retained memory or the behavior is documented as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100