Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2020-10-21 22:41:11 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2020-10-21 22:41:11 +0300
commitd2a3078460095bef0db0772eb94a0b5d3232ec84 (patch)
tree5b0a050d43b355cc18fad698fecac0c0c809a8a9 /src/inspector_profiler.cc
parentd5088d8dbbcf1cdc32e15a37e132a43e95dece2f (diff)
src: add --heapsnapshot-near-heap-limit option
This patch adds a --heapsnapshot-near-heap-limit CLI option that takes heap snapshots when the V8 heap is approaching the heap size limit. It will try to write the snapshots to disk before the program crashes due to OOM. PR-URL: https://github.com/nodejs/node/pull/33010 Refs: https://github.com/nodejs/node/issues/27552 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/inspector_profiler.cc')
-rw-r--r--src/inspector_profiler.cc20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc
index 03cf2f6e5ca..9dd3e623ec8 100644
--- a/src/inspector_profiler.cc
+++ b/src/inspector_profiler.cc
@@ -394,22 +394,6 @@ static void EndStartedProfilers(Environment* env) {
}
}
-std::string GetCwd(Environment* env) {
- char cwd[PATH_MAX_BYTES];
- size_t size = PATH_MAX_BYTES;
- const int err = uv_cwd(cwd, &size);
-
- if (err == 0) {
- CHECK_GT(size, 0);
- return cwd;
- }
-
- // This can fail if the cwd is deleted. In that case, fall back to
- // exec_path.
- const std::string& exec_path = env->exec_path();
- return exec_path.substr(0, exec_path.find_last_of(kPathSeparator));
-}
-
void StartProfilers(Environment* env) {
AtExit(env, [](void* env) {
EndStartedProfilers(static_cast<Environment*>(env));
@@ -427,7 +411,7 @@ void StartProfilers(Environment* env) {
if (env->options()->cpu_prof) {
const std::string& dir = env->options()->cpu_prof_dir;
env->set_cpu_prof_interval(env->options()->cpu_prof_interval);
- env->set_cpu_prof_dir(dir.empty() ? GetCwd(env) : dir);
+ env->set_cpu_prof_dir(dir.empty() ? env->GetCwd() : dir);
if (env->options()->cpu_prof_name.empty()) {
DiagnosticFilename filename(env, "CPU", "cpuprofile");
env->set_cpu_prof_name(*filename);
@@ -442,7 +426,7 @@ void StartProfilers(Environment* env) {
if (env->options()->heap_prof) {
const std::string& dir = env->options()->heap_prof_dir;
env->set_heap_prof_interval(env->options()->heap_prof_interval);
- env->set_heap_prof_dir(dir.empty() ? GetCwd(env) : dir);
+ env->set_heap_prof_dir(dir.empty() ? env->GetCwd() : dir);
if (env->options()->heap_prof_name.empty()) {
DiagnosticFilename filename(env, "Heap", "heapprofile");
env->set_heap_prof_name(*filename);