node-oom-heapdump 2.2.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ${{ matrix.os }}
12
12
  strategy:
13
13
  matrix:
14
- node-version: [7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 14.x]
14
+ node-version: [10.x, 11.x, 12.x, 14.x, 15.x, 16.x]
15
15
  os: [ubuntu-latest, macos-latest, windows-latest]
16
16
  steps:
17
17
  - uses: actions/checkout@v2
@@ -19,11 +19,15 @@ jobs:
19
19
  uses: actions/setup-node@v1
20
20
  with:
21
21
  node-version: ${{ matrix.node-version }}
22
+ - name: Add msbuild to PATH
23
+ if: matrix.os == 'windows-latest'
24
+ uses: microsoft/setup-msbuild@v1.1
22
25
  - name: patch node gyp on windows to support Visual Studio 2019
23
26
  if: matrix.os == 'windows-latest'
24
27
  shell: powershell
25
28
  run: |
26
- npm install --global node-gyp@5.1.1
29
+ npm install --global npm@latest
30
+ npm install --global node-gyp@latest
27
31
  npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
28
32
  - name: build using node-pre-gyp
29
33
  run: |
package/.travis.yml CHANGED
@@ -8,4 +8,6 @@ node_js:
8
8
  - "12"
9
9
  - "13"
10
10
  - "14"
11
+ - "15"
12
+ - "16"
11
13
  script: npm run dummy
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ 10-02-2022 Paul Rütter
2
+ - 3.0.1
3
+ - Fixed building native artifacts on Windows, thanks spmiller! https://github.com/blueconic/node-oom-heapdump/issues/22
4
+
5
+ 10-02-2022 Paul Rütter
6
+ - 3.0.0
7
+ - Added Node 16 support (by merging https://github.com/blueconic/node-oom-heapdump/pull/20, Thanks Simon Abbott!).
8
+ This fixes a recursion issue.
9
+ - Removed "GC_MONITORING" at it relied on `gc-stats`, which is no longer maintained (and contained security issues)
10
+ - Updated `node-pre-gyp` to `@mapbox/node-pre-gyp` so security issues are mitigated
11
+
1
12
  12-10-2020 Paul Rütter
2
13
  - 2.1.0
3
14
  - Added Node 14 support
package/README.md CHANGED
@@ -5,11 +5,16 @@ Node module which will create a V8 heap snapshot right before an "Out of Memory"
5
5
 
6
6
  It can also create heapdumps and CPU profiles on request like 'v8-profiler', but does this off-process so it doesn't interfere with execution of the main process.
7
7
 
8
- Tested on Node.js 7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x and 14.x.
9
- No support for Node.js < 7.0 at the moment (although this can be fixed if needed).
8
+ Tested on Node.js 10.x, 11.x, 12.x, 13.x, 14.x, 15.x and 16.x.
9
+ No support for Node.js < 10.x at the moment in version 3.0.0, use version 2.2.0 for if needed.
10
10
 
11
11
  Also comes with prebuilt binaries (hosted on Github releases), thanks to Stuart Miller (https://github.com/spmiller).
12
12
 
13
+ ## Node.js 14.18.x
14
+ https://github.com/nodejs/node/pull/33010 landed in Node.js 14.18.0, which makes this module no longer needed for heapdumps on out of memory.
15
+ One can use the `--heapsnapshot-near-heap-limit` Node.js CLI option as an alternative.
16
+ See https://nodejs.org/dist/latest-v14.x/docs/api/cli.html#cli_heapsnapshot_near_heap_limit_max_count.
17
+
13
18
  # Why?
14
19
  When running nodejs processes in a low memory environment, every out of memory that occurs is interesting.
15
20
  To figure out why a process went out of memory, a heap snapshot (e.g. heapdump) can help a lot.
@@ -58,17 +63,12 @@ On Node.js 12.x the latter two flags seem to cause some stability issues (see ht
58
63
 
59
64
  # Options
60
65
  * heapdumpOnOOM - boolean whether to create a heapdump when an out of memory occurs. Default true.
61
- * OOMImplementation - Either "NATIVE_HOOK" or "GC_MONITORING".
66
+ * OOMImplementation - Only "NATIVE_HOOK" is supported starting from 3.0.0
62
67
  "NATIVE_HOOK" relies on the native v8 hook and makes sure that the heapdump is actually created when the OoM occurs. It's more impacted by the OoMKiller of Unix systems though, when being run in memory restricted environments like Docker.
63
- "GC_MONITORING" is the old implementation, which relies on GC monitoring. It's less impacted by OoMKiller, because the 'threshold' parameter determines when to create the heapdump. Use this option when you run into the OoMKiller of the Unix OS. Default is "NATIVE_HOOK".
64
68
  * path - the path where the heapdump ends up when an out of memory error occurs. '.heapsnapshot' is automatically appended. Defaults to this modules' directory.
65
69
  * addTimestamp - add a timestamp to the out of memory heapdump filename, to make it unique. Default is false.
66
70
  * port - optionally, the alternative DevTools protocol port. Defaults to 9229. Should map on the port given to the --inspect arg.
67
71
 
68
- The following options are only relevant when OOMImplementation="GC_MONITORING".
69
- * limit - optionally, specify a limit to how many heapdumps will be created when being above the threshold. Default is 3.
70
- * threshold - integer between 0 and 100 (%) which determines when to make the heapdump. When the used heapSize exceeds the threshold, a heapdump is made. This value can be tuned depending on your configuration; if memory usage is very volatile, a lower value might make more sense. Default is 70.
71
-
72
72
  # API
73
73
  Besides creating heapdumps when an out of memory error occurs, there also is an API for creating heapdumps and CPU profiles on request. See below for the currently available API.
74
74
 
package/build/binding.sln CHANGED
@@ -4,14 +4,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "node_oom_heapdump_native",
4
4
  EndProject
5
5
  Global
6
6
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
7
- Debug|x64 = Debug|x64
8
7
  Release|x64 = Release|x64
8
+ Debug|x64 = Debug|x64
9
9
  EndGlobalSection
10
10
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
11
- {B44BD8E7-8AB3-68F6-9D96-154D16CEC9C0}.Debug|x64.ActiveCfg = Debug|x64
12
- {B44BD8E7-8AB3-68F6-9D96-154D16CEC9C0}.Debug|x64.Build.0 = Debug|x64
13
11
  {B44BD8E7-8AB3-68F6-9D96-154D16CEC9C0}.Release|x64.ActiveCfg = Release|x64
14
12
  {B44BD8E7-8AB3-68F6-9D96-154D16CEC9C0}.Release|x64.Build.0 = Release|x64
13
+ {B44BD8E7-8AB3-68F6-9D96-154D16CEC9C0}.Debug|x64.ActiveCfg = Debug|x64
14
+ {B44BD8E7-8AB3-68F6-9D96-154D16CEC9C0}.Debug|x64.Build.0 = Debug|x64
15
15
  EndGlobalSection
16
16
  GlobalSection(SolutionProperties) = preSolution
17
17
  HideSolutionNode = FALSE
@@ -36,6 +36,7 @@
36
36
  <ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\</ExecutablePath>
37
37
  <IgnoreImportLibrary>true</IgnoreImportLibrary>
38
38
  <IntDir>$(Configuration)\obj\$(ProjectName)\</IntDir>
39
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
39
40
  <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
40
41
  <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
41
42
  <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
@@ -47,10 +48,10 @@
47
48
  </PropertyGroup>
48
49
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
49
50
  <ClCompile>
50
- <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
51
+ <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
52
+ <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
51
53
  <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
52
54
  <BufferSecurityCheck>true</BufferSecurityCheck>
53
- <CompileAsWinRT>false</CompileAsWinRT>
54
55
  <DebugInformationFormat>OldStyle</DebugInformationFormat>
55
56
  <DisableSpecificWarnings>4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
56
57
  <ExceptionHandling>false</ExceptionHandling>
@@ -59,31 +60,38 @@
59
60
  <OmitFramePointers>false</OmitFramePointers>
60
61
  <Optimization>Disabled</Optimization>
61
62
  <PrecompiledHeader>NotUsing</PrecompiledHeader>
62
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
63
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
63
64
  <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
64
65
  <StringPooling>true</StringPooling>
65
66
  <SuppressStartupBanner>true</SuppressStartupBanner>
66
67
  <TreatWarningAsError>false</TreatWarningAsError>
67
68
  <WarningLevel>Level3</WarningLevel>
69
+ <WholeProgramOptimization>true</WholeProgramOptimization>
68
70
  </ClCompile>
71
+ <Lib>
72
+ <AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
73
+ </Lib>
69
74
  <Link>
70
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;&quot;C:\\Users\\paul.BLUECONIC\\AppData\\Local\\node-gyp\\Cache\\12.20.0\\x64\\node.lib&quot;</AdditionalDependencies>
75
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;&quot;C:\\Users\\paul.BLUECONIC\\AppData\\Local\\node-gyp\\Cache\\16.14.0\\x64\\node.lib&quot;</AdditionalDependencies>
76
+ <AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
77
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
71
78
  <GenerateDebugInformation>true</GenerateDebugInformation>
79
+ <OptimizeReferences>true</OptimizeReferences>
72
80
  <OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
73
81
  <SuppressStartupBanner>true</SuppressStartupBanner>
74
82
  <TargetExt>.node</TargetExt>
75
83
  <TargetMachine>MachineX64</TargetMachine>
76
84
  </Link>
77
85
  <ResourceCompile>
78
- <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
79
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
86
+ <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
87
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
80
88
  </ResourceCompile>
81
89
  </ItemDefinitionGroup>
82
90
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
83
91
  <ClCompile>
84
- <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
92
+ <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
93
+ <AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
85
94
  <BufferSecurityCheck>true</BufferSecurityCheck>
86
- <CompileAsWinRT>false</CompileAsWinRT>
87
95
  <DebugInformationFormat>OldStyle</DebugInformationFormat>
88
96
  <DisableSpecificWarnings>4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
89
97
  <ExceptionHandling>false</ExceptionHandling>
@@ -95,32 +103,41 @@
95
103
  <OmitFramePointers>true</OmitFramePointers>
96
104
  <Optimization>Full</Optimization>
97
105
  <PrecompiledHeader>NotUsing</PrecompiledHeader>
98
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
99
107
  <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
100
108
  <RuntimeTypeInfo>false</RuntimeTypeInfo>
101
109
  <StringPooling>true</StringPooling>
102
110
  <SuppressStartupBanner>true</SuppressStartupBanner>
103
111
  <TreatWarningAsError>false</TreatWarningAsError>
104
112
  <WarningLevel>Level3</WarningLevel>
113
+ <WholeProgramOptimization>true</WholeProgramOptimization>
105
114
  </ClCompile>
115
+ <Lib>
116
+ <AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
117
+ </Lib>
106
118
  <Link>
107
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;&quot;C:\\Users\\paul.BLUECONIC\\AppData\\Local\\node-gyp\\Cache\\12.20.0\\x64\\node.lib&quot;</AdditionalDependencies>
119
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;&quot;C:\\Users\\paul.BLUECONIC\\AppData\\Local\\node-gyp\\Cache\\16.14.0\\x64\\node.lib&quot;</AdditionalDependencies>
120
+ <AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
121
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
108
122
  <GenerateDebugInformation>true</GenerateDebugInformation>
123
+ <OptimizeReferences>true</OptimizeReferences>
109
124
  <OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
110
125
  <SuppressStartupBanner>true</SuppressStartupBanner>
111
126
  <TargetExt>.node</TargetExt>
112
127
  <TargetMachine>MachineX64</TargetMachine>
113
128
  </Link>
114
129
  <ResourceCompile>
115
- <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\12.20.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
116
- <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
130
+ <AdditionalIncludeDirectories>C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\include\node;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\src;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\config;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\openssl\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\uv\include;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\zlib;C:\Users\paul.BLUECONIC\AppData\Local\node-gyp\Cache\16.14.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
131
+ <PreprocessorDefinitions>NODE_GYP_MODULE_NAME=node_oom_heapdump_native;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
117
132
  </ResourceCompile>
118
133
  </ItemDefinitionGroup>
119
134
  <ItemGroup>
120
135
  <None Include="..\binding.gyp"/>
121
136
  </ItemGroup>
122
137
  <ItemGroup>
123
- <ClCompile Include="..\lib\node_oom_heapdump_native.cc"/>
138
+ <ClCompile Include="..\lib\node_oom_heapdump_native.cc">
139
+ <ObjectFileName>$(IntDir)\lib\node_oom_heapdump_native.obj</ObjectFileName>
140
+ </ClCompile>
124
141
  </ItemGroup>
125
142
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
126
143
  <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets"/>
package/index.js CHANGED
@@ -84,9 +84,8 @@ function parseOptions(options) {
84
84
  if (options.heapdumpOnOOM === undefined) {
85
85
  options.heapdumpOnOOM = true;
86
86
  }
87
- if (options.OOMImplementation === undefined){
87
+ if (options.OOMImplementation === undefined) {
88
88
  // default is the "new" implementation
89
- // the other option is "GC_MONITORING", which is the old implementation (which is less impacted by OoMKiller)
90
89
  options.OOMImplementation = "NATIVE_HOOK";
91
90
  }
92
91
  if (options.port === undefined) {
@@ -97,16 +96,6 @@ function parseOptions(options) {
97
96
  if (options.path === undefined) {
98
97
  options.path = "OoM-pid-" + process.pid;
99
98
  }
100
- if (options.limit === undefined) {
101
- options.limit = 3;
102
- } else {
103
- options.limit = parseInt(options.limit);
104
- }
105
- if (options.threshold === undefined) {
106
- options.threshold = 70;
107
- } else {
108
- options.threshold = parseInt(options.threshold);
109
- }
110
99
  if (options.addTimestamp === undefined) {
111
100
  options.addTimestamp = false;
112
101
  } else {
package/lib/index.js CHANGED
@@ -8,48 +8,14 @@ class NodeOomHeapDumpImpl {
8
8
  this._files = [];
9
9
  this._busy = false;
10
10
  this._count = 0;
11
- this._limitReached = false;
12
11
 
13
12
  if (this._opts.heapdumpOnOOM) {
14
13
  if (options.OOMImplementation === "NATIVE_HOOK") {
15
14
  require('bindings')('node_oom_heapdump_native.node').call(this._getHeapSnapshotPath(this._opts.path), this._opts.addTimestamp);
16
- } else if (options.OOMImplementation === "GC_MONITORING") {
17
- this._monitorHeap();
18
15
  }
19
16
  }
20
17
  }
21
18
 
22
- _monitorHeap() {
23
- // see https://www.npmjs.com/package/gc-stats
24
- let gcStats = new require('gc-stats')();
25
- gcStats.on('stats', (stats) => {
26
- // gctype 2 is a Full GC (Mark/Sweep/Compact)
27
- if (stats.gctype === 2 && !this._busy) {
28
- let memoryUsagePercentage = Math.round((stats.after.usedHeapSize / stats.after.heapSizeLimit) * 100);
29
- if (memoryUsagePercentage > this._opts.threshold) {
30
- if (this._count < this._opts.limit) {
31
- // this is a full GC and the used heap size is using more than x% of the assigned heap space limit
32
- console.warn('OoM is imminent: Full GC (Mark/Sweep/Compact) complete and still more than %s% (%s%) of the heap is used. Creating heapdump now. GC stats: ', this._opts.threshold, Math.round(memoryUsagePercentage), JSON.stringify(stats));
33
-
34
- this.createHeapSnapshot(this._opts.path, "OoM");
35
-
36
- // block execution of other code for a while (5 second) to enable snapshot to be created
37
- const time = Date.now();
38
- let diff = 0;
39
- do {
40
- diff = Date.now() - time;
41
- }
42
- while (diff < 5000);
43
- } else if (!this._limitReached) {
44
- this._limitReached = true;
45
- console.warn("OoM heapdump limit reached (%s); no more heapdumps will be created.", this._opts.limit);
46
- return;
47
- }
48
- }
49
- }
50
- });
51
- }
52
-
53
19
 
54
20
  /**
55
21
  * Calls the designated worker and returns a promise
@@ -12,6 +12,7 @@ using namespace v8;
12
12
 
13
13
  char filename[256];
14
14
  bool addTimestamp;
15
+ bool processingOOM = false;
15
16
 
16
17
  class FileOutputStream: public OutputStream {
17
18
  public:
@@ -32,7 +33,17 @@ class FileOutputStream: public OutputStream {
32
33
  FILE* stream_;
33
34
  };
34
35
 
36
+ size_t RaiseLimit(void* data, size_t current_heap_limit, size_t initial_heap_limit) {
37
+ return current_heap_limit + 10u * 1024 * 1024; // 10MiB
38
+ }
39
+
35
40
  void OnOOMError(const char *location, bool is_heap_oom) {
41
+ if (processingOOM) {
42
+ fprintf(stderr, "FATAL: OnOOMError called more than once.\n");
43
+ exit(2);
44
+ }
45
+ processingOOM = true;
46
+
36
47
  if (addTimestamp) {
37
48
  // Add timestamp to filename
38
49
  time_t rawtime;
@@ -44,7 +55,7 @@ void OnOOMError(const char *location, bool is_heap_oom) {
44
55
  pch = strstr (filename,".heapsnapshot");
45
56
  strncpy (pch,"",1);
46
57
  strcat (filename, "-%Y%m%dT%H%M%S.heapsnapshot");
47
-
58
+
48
59
  char newFilename[256];
49
60
  strftime(newFilename, sizeof(filename), filename, timeinfo);
50
61
  strcpy(filename, newFilename);
@@ -54,10 +65,19 @@ void OnOOMError(const char *location, bool is_heap_oom) {
54
65
  FILE* fp = fopen(filename, "w");
55
66
  if (fp == NULL) abort();
56
67
 
68
+ auto* isolate = v8::Isolate::GetCurrent();
69
+
70
+ // Capturing a heap snapshot forces a garbage collection which can, in turn,
71
+ // trigger the OOM flow which causes recursion. To prevent this, this callback
72
+ // will raise the heap limit if the GC tries to go down that path again.
73
+ // Normally we would want to add a call to RemoveNearHeapLimitCallback() after
74
+ // we are done, but that is not necessary since we exit() before it matters.
75
+ isolate->AddNearHeapLimitCallback(RaiseLimit, nullptr);
76
+
57
77
  // Create heapdump, depending on which Node.js version this can differ
58
78
  // for now, just support Node.js 7 and higher
59
- const HeapSnapshot* snap = v8::Isolate::GetCurrent()->GetHeapProfiler()->TakeHeapSnapshot();
60
-
79
+ const HeapSnapshot* snap = isolate->GetHeapProfiler()->TakeHeapSnapshot();
80
+
61
81
  FileOutputStream stream(fp);
62
82
  snap->Serialize(&stream, HeapSnapshot::kJSON);
63
83
  fclose(fp);
@@ -69,7 +89,7 @@ void OnOOMError(const char *location, bool is_heap_oom) {
69
89
  void ParseArgumentsAndSetErrorHandler(const FunctionCallbackInfo<Value>& args) {
70
90
  Isolate* isolate = args.GetIsolate();
71
91
  isolate->SetOOMErrorHandler(OnOOMError);
72
-
92
+
73
93
  // parse JS arguments
74
94
  // 1: filename
75
95
  // 2: addTimestamp boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-oom-heapdump",
3
- "version": "2.2.0",
3
+ "version": "3.0.1",
4
4
  "description": "Create a V8 heap snapshot when an \"Out of Memory\" error occurs, or create a heap snapshot or CPU profile on request.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,12 +40,11 @@
40
40
  "eslint-config-google": "^0.14.0"
41
41
  },
42
42
  "dependencies": {
43
+ "@mapbox/node-pre-gyp": "^1.0.8",
43
44
  "bindings": "^1.5.0",
44
45
  "chrome-remote-interface": "^0.28.2",
45
- "gc-stats": "^1.4.0",
46
46
  "nan": "^2.14.2",
47
- "node-pre-gyp": "^0.17.0",
48
47
  "require-main-filename": "^2.0.0",
49
- "ws": "^7.4.1"
48
+ "ws": "^7.4.6"
50
49
  }
51
50
  }