Node: v4.0 force garbage collector

Created on 11 Sep 2015  路  8Comments  路  Source: nodejs/node

Hi,

In the previous version of Node, I was forcing the garbage collector running node with the flag --expose-gc calling global.gc() in the code. This doesn't seem to work in the version 4.0.
Is there any way to do that?

Thanks.

question

Most helpful comment

V8 command line switches should come before script filenames. Closing, not a bug.

All 8 comments

--js-flags="--expose-gc"

@bricss What?

@jd78 What's the exact problem? Is there no such function or is the memory not collected?

@bricss still not working.

@ChALkeR yes, no function. I get the error "global.gc is not a function"

Still works: node --expose_gc -p global.gc prints [Function: gc], ditto for -p gc.

I see. But the problem persists.

I tried to run the app as follow:

  • node server\www --expose-gc
  • node server\www --expose_gc
  • node server\www --js-flags="--expose-gc"

In all cases I get the error when I do global.gc();

The same code was working with the version 12.7.

@jd78 Does just gc() work?

V8 command line switches should come before script filenames. Closing, not a bug.

@bnoordhuis Thanks, that did the job.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seishun picture seishun  路  3Comments

mcollina picture mcollina  路  3Comments

cong88 picture cong88  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments

vsemozhetbyt picture vsemozhetbyt  路  3Comments