allow set directory for heapsnapshotΒ #39493
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
Description
Is your feature request related to a problem? Please describe.
Please describe the problem you are trying to solve.
the --heapsnapshot-signal and --heap snapshot-near-heap-limit is very handy when dealing with memory issues.
if we can add a flag to allow setting the directory where the heap snapshop is written to, it would give a lot of flexibility.
Describe the solution you'd like
Please describe the desired behavior.
allow set the directory where heap snapshot is written to
Describe alternatives you've considered
Please describe alternative solutions or features you have considered.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.
Activity
gireeshpunathil commentedon Jul 31, 2021
looks like a valid requirement to me!
himadriganguly commentedon Aug 6, 2021
I would like to pick this up. Can you please assign this to me?
gireeshpunathil commentedon Aug 6, 2021
@himadriganguly - no need of assignment, the above note is sufficient. go ahead!
himadriganguly commentedon Aug 6, 2021
Ok. Thank you.
simllll commentedon Jan 17, 2022
Is this possible already somehow?
tholcman commentedon May 4, 2022
Hi,
for those who haven't found it yet:
and
works for us, but I guess the same override as with --cpu-prof-dir and others should be possible.
sergeyampo commentedon Oct 13, 2022
If I run node with next flags:
and try to send a SIGUSR2 signal to a running process I'll notice that .heapsnapshot file will be generated in working directory and --diagnostic-dir flag will be ignored.
Suddenly, --heapsnapshot-near-heap-limit flag generates a snapshot file in --diagnostic-dir directory.
I think it's a bug and it's reproduced on LTS node version 16.18.0 and on 18.10.0 too.
bnoordhuis commentedon Oct 14, 2022
Do you have the
heapdumpmodule installed? Iffind node_modules -name \*heapdump*prints anything, the answer is 'yes'.mhdawson commentedon Oct 21, 2022
@bnoordhuis I think their comment is about the heapsnapshot functionality built into node core versus the external module?
bnoordhuis commentedon Oct 21, 2022
If you load node-heapdump, it overrides node's own SIGUSR2 handler. You'll get snapshots but not in the directory you specified.
mhdawson commentedon Oct 24, 2022
@bnoordhuis got it thanks.
bnoordhuis commentedon Dec 29, 2022
Original feature request has been implemented and no follow-up from @sergeyampo so I'm going to go ahead and close this as done.
thefloweringash commentedon Mar 27, 2023
I'm also seeing this behavior. Specifically the handler for the signal does not use the diagnostic directory.
Looking at the code,
Environment::NearHeapLimitCallbackusesdiagnostic_dirnode/src/env.cc
Lines 1830 to 1842 in 38e6ac7
but
TriggerHeapSnapshot(without an explicit filename) does not:node/src/heap_utils.cc
Lines 456 to 457 in 38e6ac7
SteffenLanger commentedon May 17, 2023
In case anyone else finds this issue and wonders about a solution for @thefloweringash's message: There is a pending pull request by @MrJithil πͺπΌ