--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/3cfcd97a-47c7-42fe-9a4e-e11f0b705db1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Regards,
Tim.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.
I'm trying to figure out how much memory different objects take up in Chrome. To be more specific, I'm interested in objects that were parsed from JSON. I've been using the DevTools memory profiler for that, and I've found some interesting things. However, I'm getting really confused about the memory overhead incurred by each object property/key (including the key string).
One of the experiments I did was create two objects with the same number of properties and the same amount of data in the property values, but different property key lengths (attachments obj1.jpg and obj2.jpg). Note that both keys and values are random strings, so there are no duplicate key names. The memory profile reports that both objects have the exact same retained size...weird!
So I made a number of objects with different amounts of properties to see how the memory the profile attributes to "properties" changes (attachment obj3.jpg). So there seems to be sudden jump in the size of "properties", in this case between when having more than 85 properties. The same behavior is observable with less or more properties: the size of "properties" remains at a certain level and then suddenly jumps by a lot when some magic number of properties is hit. That suggests that Chrome is allocating a block of memory to store the current and potential future properties, and when it runs out of memory in that block, it increases the size of the block significantly (factor of 4?).
Ok, so 1564 bytes for 85-ish properties, that's about 18 bytes per property. With keys of 10 characters (as in my experiment), that seems to make a lot of sense. So if I double the key size to 20 characters, the jump from 1564 to 6172 bytes should happen somewhere around 43 properties, right? But no! Even with keys twice as long, the jump
There seems to be a flaw in the calculations. A 10 character string takes 24 bytes (I can see you're on a 32-bit platform, right), so for 85 keys it'd need at least 85*24=2040 bytes, i.e. 1564 won't fit all the keys. I wonder you are keeping other references to the keys from somewhere else, e.g. from referenceObjParsed object? If yes the strings won't be counted as a retained by the properties array.
Hi AlexeiThere seems to be a flaw in the calculations. A 10 character string takes 24 bytes (I can see you're on a 32-bit platform, right), so for 85 keys it'd need at least 85*24=2040 bytes, i.e. 1564 won't fit all the keys. I wonder you are keeping other references to the keys from somewhere else, e.g. from referenceObjParsed object? If yes the strings won't be counted as a retained by the properties array.
Sort of: referenceObjParsed is a JSON stringified and parsed version of referenceObj. Is V8 able to handle that smartly?
If I don't create such a copy, things look a little different, but even more confusing (to me, at least). For example, "properties" has a different shallow and retained size in that case (obj5.jpg).
I would understand if that were the case when the object had been copied (like in the examples I've pasted previously), but in this case, it hasn't. Also, I was surprised to see that sometimes an object with more properties uses less memory than an object with fewer properties (obj6.jpg and obj7.jpg).
If I don't create such a copy, things look a little different, but even more confusing (to me, at least). For example, "properties" has a different shallow and retained size in that case (obj5.jpg).Shallow size is the size of the properties array itself (an array of references to both keys and values). Retained size adds sizes of all objects referenced from this array (and not references from elsewhere, to be precise). These are strings in your case.