Newbie question - How to deploy node.js with manual garbage collection in app engine?

1,436 views
Skip to first unread message

Andrew Marunchak

unread,
Dec 14, 2020, 12:02:33 PM12/14/20
to Google App Engine
I'm running manual garbage collection every 30 seconds via  global.gc(); and my app.yaml file contains:

entrypoint: node --expose_gc server

However, when deploying, I eventually see a startup error displaying:

Updating service [default] (this may take several minutes)...failed.ERROR: (gcloud.app.deploy) Error Response: [9]Application startup error! Code: APP_CONTAINER_CRASHED  

Any insight would be greatly appreciated :[

Elliott (Cloud Platform Support)

unread,
Dec 14, 2020, 1:26:53 PM12/14/20
to Google App Engine

Hello Andrew,

From what you told us about, I see that you’ve figured out calling garbage collection manually. I was able to find this link in Stackoverflow regarding garbage collection for Nodejs generally. Please tell me if this applies but I think it does.

If you launch the node process with the --expose-gc flag, you can then call global.gc() to force node to run garbage collection. Keep in mind that all other execution within your node app is paused until GC completes, so don't use it too often or it will affect performance.

You might want to include a check when making GC calls from within your code so things don't go bad if node was run without the flag:

try {
  if (global.gc) {global.gc();}
} catch (e) {
  console.log("`node --expose-gc index.js`");
  process.exit();
}

The second part of your question is why it does not work. The error you provided from the deployment command would be the next step but Google Groups is meant for general discussions. 

I may check for a common issue if you may provide a timestamp of when you saw the message.
Reply all
Reply to author
Forward
0 new messages