chad3814 / node-hashtable

Native hashtable interface for when V8 objects can't take the heat
MIT License
106 stars 41 forks source link

Segmentation fault #17

Closed akaustel closed 9 years ago

akaustel commented 9 years ago

I'm not sure if it is related, but it would seem that the when I reach 4GiB of memeory usage the result is a segmentation fault:

Segmentation fault

or JS Allocation failed:

FATAL ERROR: JS Allocation failed - process out of memory
Aborted

I'm on Linux (Mint 64-bit).

The code that produces this problem:

var HashTable = require('hashtable');
var crypto = require('crypto');

var hashtable = new HashTable();
hashtable.reserve(20000000);

for(var n=0; n<17576; n++) {
    for(var i=0; i<1000; i++) {
        var regno =  n.toString(26) +'-'+ i;
        hashtable.put(crypto.createHash('sha1').update(regno).digest('hex'), regno);
    }
    if (n%100 === 0) {
        console.log("n,i,reg", n,i,regno);
    }
}
chad3814 commented 9 years ago

Well, hashtable since version 0.4.0 can have any v8 Value as a key or value and not just strings. That means that the objects need to be retained within v8, and I'm pretty sure v8 is still 32-bit capped.

I'm thinking of changing hashtable back to only using strings as keys and values, in that case, in a 64-bit os and executable you could probably get more than 4GB stored.