Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: design pattern to avoid memory leaks #98

Open
chirag04 opened this issue Jul 15, 2013 · 2 comments
Open

question: design pattern to avoid memory leaks #98

chirag04 opened this issue Jul 15, 2013 · 2 comments

Comments

@chirag04
Copy link

Hi @addyosmani ,

Your design pattern book is awesome. I am working with nodejs and need some advice on scenarios like below:

Lets say i have a function that makes persistent tcp connection to say twitter and does all the parsing on that.
Eg:

function addTwitter(somedata) {

   var twit = new Twitter(somedata);
   twit.on('twit', function(err,data) {
      //do something here
      // use somedata variable here.
   }

}

addTwitter(somehandle);
addTwitter(anotherhandle);

so basically this addTwitter is used to make multiple connections to twitter server.

I am wondering if this style will leak memory. Also, If there is a better way of doing this.

@addyosmani
Copy link
Owner

I actually think there would be huge value in adding a section on memory leak patterns. Good suggestion. I've recently given a talk on a similar subject - slides here: https://speakerdeck.com/addyosmani/javascript-memory-management-masterclass and might be able to extract some of this info into a chapter in the future.

@chirag04
Copy link
Author

chirag04 commented Sep 1, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants