Issues
- 0
V8 provides [v8::Isolate::AddNearHeapLimitCallback()](https://source.chromium.org/chromium/chromium/src/+/master:v8/include/v8.h;bpv=1;bpt=1;l=9343?originalUrl=https:%2F%2Fcs.chromium.org%2F&gsn=AddNearHeapLimitCallback&gs=kythe%3A%2F%2Fchromium.googlesource.com%2Fchromium%2Fsrc%3Flang%3Dc%252B%252B%3Fpath%3Dsrc%2Fv8%2Finclude%2Fv8.h%23RJGJDE44AxlIHgLihqvHnOXXbWkTVPQNjeG939U-FYQ) for adjusting the heap limit when V8 is approaching it. The debugger implementation in V8 uses this to break at the point where the heap size limit is near in the Chrome DevTools. I did a proof of concept `--heapsnapshot-near-heap-limit` implementation (https://github.com/nodejs/node/pull/33010), it does work if I just write a snapshot to disk in that callback. I temporarily raise the heap size limit to a value slightly bigger than the original limit until the snapshot is done, and tells V8 to restore to the initial limit later. There are some observations with this approach:
#1 opened by Leaking