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

best practices example in readme #64

Open
nickdesaulniers opened this issue Nov 4, 2015 · 0 comments
Open

best practices example in readme #64

nickdesaulniers opened this issue Nov 4, 2015 · 0 comments

Comments

@nickdesaulniers
Copy link

HI there, I've been monitoring memory usage with

top -pid `pgrep -n node`

I've found that if the callback function passed as the second argument closes over another variable it's better to use the pattern:

var obj1;
weak(obj2, function x () {
  use(obj1);
  x = null;
});

Than it is to do:

var obj1;
function x () {
  use(obj1);
};
weak(obj2, x);

For my app, the first stabilizes around 722 MB of memory, while the second stabilizes at 1.8 GB. Not sure why/if this is useful.

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

No branches or pull requests

1 participant