Reputation: 308
In Node.js 0.12.x maximum size of the buffer was limited by allocatable memory, which size could be got with:
require('smalloc').kMaxLength;
The actual value of kMaxLength
was hardcoded in old versions of V8 and was equal to 0x3fffffff
.
The problem is there is no smalloc
module in io.js >=3.x (including node.js 4.x). It was mentioned that Buffer
implementation was rewritten in V8 4.4.x.
So, my question is: is there a way to get the maximum size of the Buffer (and/or allocatable memory) in io.js >= 3.x ?
Upvotes: 0
Views: 1520
Reputation: 8263
This file "calculated" (https://github.com/v8/v8-git-mirror/blob/4.4.63/src/objects.h) also has fixed constant for the external array.
4642 // Maximal acceptable length for an external array.
4643 static const int kMaxLength = 0x3fffffff;
EDIT:
It looks like you can use require('buffer').kMaxLength;
That was the change in 3.0 and still in 4.0
b625ab4242 - buffer: fix usage of kMaxLength (Trevor Norris) #2003
Upvotes: 2