Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 163397a

Browse filesBrowse files
indutnyaddaleax
authored andcommitted
process: add process.memoryUsage.external
PR-URL: #9587 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent d83cb48 commit 163397a
Copy full SHA for 163397a

File tree

Expand file treeCollapse file tree

4 files changed

+11
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+11
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/process.md‎

Copy file name to clipboardExpand all lines: doc/api/process.md
+5-1Lines changed: 5 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ added: v0.1.16
11751175
* `rss` {Integer}
11761176
* `heapTotal` {Integer}
11771177
* `heapUsed` {Integer}
1178+
* `external` {Integer}
11781179

11791180
The `process.memoryUsage()` method returns an object describing the memory usage
11801181
of the Node.js process measured in bytes.
@@ -1191,11 +1192,14 @@ Will generate:
11911192
{
11921193
rss: 4935680,
11931194
heapTotal: 1826816,
1194-
heapUsed: 650472
1195+
heapUsed: 650472,
1196+
external: 49879
11951197
}
11961198
```
11971199

11981200
`heapTotal` and `heapUsed` refer to V8's memory usage.
1201+
`external` refers to the memory usage of C++ objects bound to JavaScript
1202+
objects managed by V8.
11991203

12001204
## process.nextTick(callback[, ...args])
12011205
<!-- YAML
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ namespace node {
103103
V(exponent_string, "exponent") \
104104
V(exports_string, "exports") \
105105
V(ext_key_usage_string, "ext_key_usage") \
106+
V(external_string, "external") \
106107
V(external_stream_string, "_externalStream") \
107108
V(family_string, "family") \
108109
V(fatal_exception_string, "_fatalException") \
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,11 +2247,15 @@ void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
22472247
Number::New(env->isolate(), v8_heap_stats.total_heap_size());
22482248
Local<Number> heap_used =
22492249
Number::New(env->isolate(), v8_heap_stats.used_heap_size());
2250+
Local<Number> external_mem =
2251+
Number::New(env->isolate(),
2252+
env->isolate()->AdjustAmountOfExternalAllocatedMemory(0));
22502253

22512254
Local<Object> info = Object::New(env->isolate());
22522255
info->Set(env->rss_string(), Number::New(env->isolate(), rss));
22532256
info->Set(env->heap_total_string(), heap_total);
22542257
info->Set(env->heap_used_string(), heap_used);
2258+
info->Set(env->external_string(), external_mem);
22552259

22562260
args.GetReturnValue().Set(info);
22572261
}
Collapse file

‎test/parallel/test-memory-usage.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-memory-usage.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ var r = process.memoryUsage();
66
assert.ok(r.rss > 0);
77
assert.ok(r.heapTotal > 0);
88
assert.ok(r.heapUsed > 0);
9+
assert.ok(r.external > 0);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.