Don't test amount of memory you can allocate by allocating a single
big array. There are limits on array's length (and having a single
huge array is a bad idea anyway). Allocate many middle sized ones
instead in a tree structure:
function tree(depth, width) {
if (depth === 0) return new Array(1024*1024);
var node = new Array(width);
for (var i = 0; i < width; i++) node[i] = tree(depth - 1, width);
return node;
}
var t = null;
while (true) {
var nt = tree(12, 2);
nt.prev = t;
t = nt;
}
[24117] 35049 ms: Scavenge 7921.1 (8082.0) -> 7921.1 (8082.0) MB, 3
ms (+ 4 ms in 1 steps since last GC) [Runtime::PerformGC] [incremental
marking delaying mark-sweep].
#
# Fatal error in JS
# Allocation failed - process out of memory
#
zsh: trace trap (core dumped) out/x64.release/d8
--max-old-space-size=8048 --trace-gc ~/test.js
--
Vyacheslav Egorov
On Fri, Sep 21, 2012 at 9:18 AM, Krowten <[email protected]> wrote:
> Hi!
> How to use an 8 gb memory?
> ===
> var ph = [];
> while (true) {
> ph.push('7232985jkdjf');
> }
>
> node --trace-gc --max-old-space-size=8192 heaptest.js
>
> 31 ms: Scavenge 2.1 (35.0) -> 1.8 (36.0) MB, 0 ms [allocation failure].
> 33 ms: Scavenge 2.6 (36.0) -> 2.4 (36.0) MB, 0 ms [Runtime::PerformGC].
> .............
> 4641 ms: Mark-sweep 1067.6 (1102.0) -> 641.2 (675.6) MB, 752 ms
> [Runtime::PerformGC] [GC in old space requested].
> FATAL ERROR: JS Allocation failed - process out of memory
> --
> server >> ubuntu 64x
> node -p -e "process.arch" >> x64
> node -v >> v0.8.9
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en