Skip to content


Memory leak #4

TrevorBurnham opened this Issue · 2 comments

1 participant


Consider the following simple code that counts from 1 to 100 million:

var max, nextNumber, num;
num = bigint(0);
max = bigint(10).pow(8);
(nextNumber = function() {
  num = num.add(1);
  if ( {
    return process.nextTick(nextNumber);

When I run this, node process starts gradually eating up gigabytes of virtual memory, when it should be using practically none, since process.nextTick gives Node the opportunity to perform garbage collection.

I've verified that there are no memory issues when using standard numbers in this fashion, even when those numbers are being written to a file and/or a new object is used to store each number.


I don't have much experience with C++, but I'm given to believe that the solution is to add free calls corresponding to the existing malloc calls, in a function that's invoked by V8 upon garbage collection. This answer as StackOverflow gives some pointers on how to do that.


Retested under 0.3.0, after draggor's commit that frees memory on object destruction. No apparent memory leakage now. Closing the issue. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.