diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-23 11:47:28 +0800 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-05-26 22:18:00 +0200 |
commit | 4b74dae6b2601ee8be3b16fed48986f1be49f20a (patch) | |
tree | d9dde6a3876ade51a6857cf46b242ea59ce9e5ef /src/node_options.cc | |
parent | e2c0c0c68074c539ae2ae30debdeafb9f94d989b (diff) | |
download | android-node-v8-4b74dae6b2601ee8be3b16fed48986f1be49f20a.tar.gz android-node-v8-4b74dae6b2601ee8be3b16fed48986f1be49f20a.tar.bz2 android-node-v8-4b74dae6b2601ee8be3b16fed48986f1be49f20a.zip |
inspector: implement --heap-prof
In addition implements --heap-prof-name, --heap-prof-dir and
--heap-prof-interval.
These flags are similar to --cpu-prof flags but they are meant
for the V8 sampling heap profiler instead of the CPU profiler.
PR-URL: https://github.com/nodejs/node/pull/27596
Fixes: https://github.com/nodejs/node/issues/27421
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/node_options.cc')
-rw-r--r-- | src/node_options.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/node_options.cc b/src/node_options.cc index 37aefca1e4..da7a49231f 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -168,6 +168,19 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) { } } + if (!heap_prof) { + if (!heap_prof_name.empty()) { + errors->push_back("--heap-prof-name must be used with --heap-prof"); + } + if (!heap_prof_dir.empty()) { + errors->push_back("--heap-prof-dir must be used with --heap-prof"); + } + // We can't catch the case where the value passed is the default value, + // then the option just becomes a noop which is fine. + if (heap_prof_interval != kDefaultHeapProfInterval) { + errors->push_back("--heap-prof-interval must be used with --heap-prof"); + } + } debug_options_.CheckOptions(errors); #endif // HAVE_INSPECTOR } @@ -369,6 +382,24 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "Directory where the V8 profiles generated by --cpu-prof will be " "placed. Does not affect --prof.", &EnvironmentOptions::cpu_prof_dir); + AddOption( + "--heap-prof", + "Start the V8 heap profiler on start up, and write the heap profile " + "to disk before exit. If --heap-prof-dir is not specified, write " + "the profile to the current working directory.", + &EnvironmentOptions::heap_prof); + AddOption("--heap-prof-name", + "specified file name of the V8 CPU profile generated with " + "--heap-prof", + &EnvironmentOptions::heap_prof_name); + AddOption("--heap-prof-dir", + "Directory where the V8 heap profiles generated by --heap-prof " + "will be placed.", + &EnvironmentOptions::heap_prof_dir); + AddOption("--heap-prof-interval", + "specified sampling interval in bytes for the V8 heap " + "profile generated with --heap-prof. (default: 512 * 1024)", + &EnvironmentOptions::heap_prof_interval); #endif // HAVE_INSPECTOR AddOption("--redirect-warnings", "write warnings to file instead of stderr", |