question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

memory leak when instance is created inside a function.

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

25reactions
Qix-commented, Apr 4, 2019

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.

18reactions
brandonroscommented, Apr 3, 2019

@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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

memory leak when instance is created inside a function. #678
Hi, I just noticed that when you create debug instance in a function, it is starting to leak the memory without freeing.
Read more >
Does calling a function that creates object cause memory leak?
Yes, it will create 10 new objects if called 10 times. No, this doesn't cause a memory leak1. One of the main points...
Read more >
Causes of Memory Leaks in JavaScript and How to Avoid Them
In this article, we will explore programming patterns that cause memory leaks in JavaScript and explain how to improve memory management.
Read more >
How to escape from memory leaks in JavaScript
In simple words, a memory leak is an allocated piece of memory that the JavaScript engine is unable to reclaim. The JavaScript engine...
Read more >
Understanding Memory Leaks in Nodejs | by Chidume Nnamdi
In our effort to understand what a memory leak… ... These make them to be created inside the function's or object's scope, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found