3 ms·
I don't even know if this can be considered the "closure" pattern anymore, but I wanted to try to get method sharing among the objects by doing something like t
by nxn 16y ago
I don't even know if this can be considered the "closure" pattern anymore, but I wanted to try to get method sharing among the objects by doing something like this: https://gist.github.com/877259 https://gist.github.com/877259
The hope was that since the functions were created and bound within the function literal, the "create" method could simply assign references to the existing functions instead of creating a new function each time (ie, avoid what munificent mentioned).
Funny thing is, even though the last line indicates that the first and last objects' "ten" method is actually shared between them, I'm still getting about 370 MB of memory usage after creating 1 million objects. I am under assumption that the cause of this memory increase is the fact that each one of the million objects has its own local references to each of the 10 functions. When I put the 10 functions inside of the "create" method, memory usage goes up again to roughly 750 MB.