Files
meteor/tools/utils/gc.js
Ben Newman 25f003d0bc Throttle requestGarbageCollection to once per 500ms.
With Meteor 1.6 / Node 8, I noticed _buildLocalPackages taking multiple
seconds on initial server startup and restart, and the problem seems to be
that we call the global.gc function too often. This wasn't a problem in
previous versions of Node, as far as I know, but it makes sense to heed
the comment in tools/utils/gc.js, now that it matters.
2017-07-13 20:10:37 -04:00

11 lines
432 B
JavaScript

import { throttle } from "underscore";
export const requestGarbageCollection =
// For this global function to be defined, the --expose-gc flag must
// have been passed to node at the bottom of the ../../meteor script,
// probably via the TOOL_NODE_FLAGS environment variable.
typeof global.gc === "function"
// Restrict actual garbage collections to once per 500ms.
? throttle(global.gc, 500)
: function () {};