From e9ecfdd20ac3f8a9d920bbcc4e5dd25bd262b4b7 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 17 Dec 2022 17:25:51 -0500 Subject: fix(runtime): `Deno.memoryUsage().rss` should return correct value (#17088) This commit changes implementation of "Deno.memoryUsage()" to return correct value for "rss" field. To do that we implement a specialized function per os to retrieve this information. --- cli/tests/unit/os_test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/os_test.ts b/cli/tests/unit/os_test.ts index 72e0b57ba..5e88f02c1 100644 --- a/cli/tests/unit/os_test.ts +++ b/cli/tests/unit/os_test.ts @@ -272,3 +272,12 @@ Deno.test({ permissions: { sys: ["gid"] } }, function getGid() { assert(gid > 0); } }); + +Deno.test(function memoryUsage() { + const mem = Deno.memoryUsage(); + assert(typeof mem.rss === "number"); + assert(typeof mem.heapTotal === "number"); + assert(typeof mem.heapUsed === "number"); + assert(typeof mem.external === "number"); + assert(mem.rss >= mem.heapTotal); +}); -- cgit v1.2.3