Hacker News new | ask | show | jobs
by rondale_sc 5386 days ago
Yes I suppose that's true. I think it all depends on what your case is and preference, but yes memory is an issue with the module method. Just out of curiosity what are the best tools out there to test memory consumption of javascript snippets? It'd be interesting to see prototype/module/whatever_else memory usage side by side.
2 comments

The browsers are getting better at optimizing memory use for small closures all the time, but there's still a long way to go. Here's a screenshot of the Chrome heap profiler for both cases:

http://cl.ly/A5NX

I have one question. How to handle private methods in prototype/module pattern? If I declare private function in obj function declaration I can not access it in public functions attached to the prototype of obj. This is also true for module pattern. This problem arises when I need to add extra method later. How to overcome this situation?
You can use a heap snapshot in Chrome Dev Tools. It has a handy feature where you take multiple snapshots and it shows you the differences in memory usage between them. See: http://code.google.com/chrome/devtools/docs/heap-profiling.h...
I'll definitely be looking into that. Thanks.