worker: add flag to control old space size
This adds a new flag --thread-max-old-space-size
(name completely
provisional). This flag lets the user configure the size of the main
thread's old space size. This has two advantages over the existing
--max-old-space-size
flag:
- It allows setting the old space size for the main thread and using
resourceLimits
for worker threads. CurrentlyresourceLimits
will be ignored when--max-old-space-size
is set (see the attached issues). - It is implemented using V8's public API, rather than relying on V8's internal flags whose stability and functionality are not guaranteed.
The downside is that there are now two flags which (in most cases) do
the same thing, so it may cause some confusion. I also think that we
should deprecate --max-old-space-size
, since the semantics feel pretty
error-prone, but that's a story for another day.
Refs: https://github.com/nodejs/node/issues/41066 Refs: https://github.com/nodejs/node/issues/43991 Refs: https://github.com/nodejs/node/pull/43992