I came across this trying to use a Javascript object to provide O(1)
indexing for sets and sorted sets.

I tried the following in Node.js:

var set = {};
var testMemoryUsage = function() {
  var length = 1000000;
  var id = 'testing';
  while (length--) {
    set[id + length] = id + length;
  }
};

I ran the function and then watched memory usage in Activity Monitor.
On each of several attempts, the process would start out with 20mb and
then grow to more than 170mb and never come down again, even after
several minutes.

The same thing happens in Chrome, but it goes up to 122mb.

Of course the set variable is never dereferenced, but the data stored
therein is in the order of 25mb. So one would expect the process to
sit at (20mb + 25mb = 45mb). Give or take a few mb for V8
implementation. But 170mb is surprising. Worse, this appears to scale
with the size of the dictionary.

Anyone have any idea what this could be?

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

Reply via email to