best practices example in readme
nickdesaulniers opened this issue · 0 comments
nickdesaulniers commented
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.