1

I have read past answers as to what is the memory size of a javascript object. Most or all of them seemed to not add up things like the link to the prototype or constructor of the object, and I wonder if an object's memory size is not in fact much more than the amount of the stuff explicitly defined for it by user code. Furthermore I may assume there's memory overheads for V8 or whatever other javascript engine, in every created object.

What would be a rough estimate of the real memory overhead of a javascript object on top of its "user defined" properties? or as an example, the real size of a bare-bones object that holds, say, just one string and one link to another object?

I have gone through old questions on this site about it, and they didn't quite cut through in a very clear or fully reasoned way (in my view).

matanster
  • 15,072
  • 19
  • 88
  • 167
  • Not the best answer, but since you mentioned v8, you could create an object and dump the heap of the VM. Chrome can analyze the file for you. – Brandon Nov 25 '13 at 00:50
  • I was not sure how to interpret the output of that @Brandon, in chrome dev tools - the output leaves room for speculation. But thanks, it's a great idea. – matanster Nov 25 '13 at 08:38
  • As a naive example, here's sample code that seems _not to take into account_ any of the "overheads" that exceed the user coded properties of an object: http://code.stephenmorley.org/javascript/finding-the-memory-usage-of-objects/ – matanster Nov 25 '13 at 08:39
  • 2
    Thanks meta guys for marking the question as "already has an answer before". I invite you to read those answers for yourselves and see how useless they are, even though they are technically marked answered. You should probably reconsider. – matanster Nov 25 '13 at 08:43

0 Answers0