debug: memory leak when instance is created inside a function.
Hi, I just noticed that when you create debug instance in a function, it is starting to leak the memory without freeing. Here’s how you can reproduce it:
const debug = require('debug');
const loop = () => {
const d = debug('namespace:that:i:want:for:this:function');
d('hello world');
setImmediate(loop);
};
loop();
If you run this and look at memory, it is leaking a lot without freeing them. also does not matter if I set environment to DEBUG=* or not, it still leaks. Any thoughts?
EDIT: tested on 3.1.1 and 4.1.1 as well (had 3.1.1 version and then I upgraded to latest one to check if it was fixed).
EDIT2: using node version 10.13 and Windows 10 x64.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 22 (13 by maintainers)
Commits related to this issue
- Avoiding recreating logger for the namespace which has been already created. Fix memory leak for a fixed number of categories. For dynamic categories method destroy is still required. #678 — committed to victor-cr/debug by deleted user 5 years ago
- Fixed lint errors #678 — committed to victor-cr/debug by deleted user 5 years ago
- fix: debug memory leak See: https://github.com/visionmedia/debug/issues/678 — committed to opencollective/opencollective-api by kewitz 4 years ago
- fix: debug memory leak See: https://github.com/visionmedia/debug/issues/678 — committed to opencollective/opencollective-api by kewitz 4 years ago
- Cache the dynamic debug instances to avoir leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to fpavageau/microgateway-plugins by fpavageau 4 years ago
- Cache the dynamic debug instances to avoid leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to fpavageau/microgateway-plugins by fpavageau 4 years ago
- Cache the dynamic debug instances to avoid leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to fpavageau/microgateway-plugins by fpavageau 4 years ago
- Cache the dynamic debug instances to avoid leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to apigee/microgateway-plugins by fpavageau 4 years ago
- Cache the dynamic debug instances to avoid leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to apigee/microgateway-plugins by fpavageau 4 years ago
- Cache the dynamic debug instances to avoid leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to apigee/microgateway-plugins by fpavageau 4 years ago
- Cache the dynamic debug instances to avoid leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to apigee/microgateway-plugins by fpavageau 4 years ago
- Cache the dynamic debug instances to avoid leaking them This is due to https://github.com/visionmedia/debug/issues/678. Fixes #174 — committed to apigee/microgateway-plugins by fpavageau 4 years ago
Hi @brandonros, I’m currently dealing with moving into my new apartment across the planet, a full time job, a new full time job on the way, and some heavy family issues.
Nobody is paying me to do any of this.
I have been primarily mobile for the last 3 weeks. I have little problem responding to issues on GH, but am relatively incapable of doing much coding.
I’m not sorry my schedule doesn’t revolve around you, sir.
@Qix- The open source community amazes me. The time it took you to tell me to open a PR, you could have opened the PR…
You’re right; a
WeakSet
could have been used to implement this if need be, but it turns out this isn’t necessary.I went ahead and proposed a fix in #740 because frankly I’m tired of people bringing this issue up, lol.
Please test it.