Status: Accepted
Owner: [email protected]
Labels: Type-Bug Priority-Medium

New issue 2211 by [email protected]: Requesting IdentityHash would attach a 412 (824 bytes on x64) dictionary to an JSObject
http://code.google.com/p/v8/issues/detail?id=2211

When IdentityHash is requested we put it into object's hidden properties.

If object does not have any hidden properties (which is usually the case) we will try to allocate StringDictionary for that with initial capacity of 5.

This initial capacity of 5 (which seems too big by itself) is however bumped up to 32 by HashTable<Shape, Key>::ComputeCapacity.

So to store a single int32 number we end up allocating

kPointerSize * (FixedArray::kHeaderSize + HashTable::kPrefixStartIndex + StringDictionaryShape::kPrefixSize + StringDictionaryShape::kEntrySize * 32) = kPointerSize * (2 + 3 + 2 + 3 * 32) = 103 * kPointerSize.

This is approximately 100 wasted words, because objects with identity hash most probably never ever will get any other hidden properties (imagine objects used as keys in a Harmony Map or stored in Harmony Set).

IdentityHash API is also seems to be used by WebKit: on NPAPI border
and by structured clone algorithm (SerializedScriptValue) which is employed by Indexed DB, webintents, postMessage, workers and probably other places. This can lead to unexpected memory consumption by complex web apps.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to