Skip to content

Commit fd33a53

Browse files
author
majianhan
committed
src: add comment explaining UINT64_MAX to 0 mapping
1 parent d062f4e commit fd33a53

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/node_process_methods.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,11 @@ static void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
251251

252252
static void GetConstrainedMemory(const FunctionCallbackInfo<Value>& args) {
253253
uint64_t value = uv_get_constrained_memory();
254-
// UINT64_MAX means a constraining mechanism exists but no limit is set.
255-
// Map to 0 per documented behavior: "If there is no constraint, 0 is returned."
254+
// When cgroups are enabled but no memory limit is set (e.g. a default
255+
// Docker container without --memory), libuv returns UINT64_MAX instead of 0.
256+
// UINT64_MAX is not a meaningful memory constraint, so map it to 0 to
257+
// indicate "no constraint", consistent with the documented behavior of
258+
// process.constrainedMemory(): "If there is no constraint, 0 is returned."
256259
if (value == UINT64_MAX) value = 0;
257260
args.GetReturnValue().Set(static_cast<double>(value));
258261
}

0 commit comments

Comments
 (0)