summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/os.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/os.ts')
-rw-r--r--ext/node/polyfills/os.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts
index 06de4ad44..d1f5e7bfa 100644
--- a/ext/node/polyfills/os.ts
+++ b/ext/node/polyfills/os.ts
@@ -159,7 +159,14 @@ export function endianness(): "BE" | "LE" {
/** Return free memory amount */
export function freemem(): number {
- return Deno.systemMemoryInfo().free;
+ if (Deno.build.os === "linux") {
+ // On linux, use 'available' memory
+ // https://github.com/libuv/libuv/blob/a5c01d4de3695e9d9da34cfd643b5ff0ba582ea7/src/unix/linux.c#L2064
+ return Deno.systemMemoryInfo().available;
+ } else {
+ // Use 'free' memory on other platforms
+ return Deno.systemMemoryInfo().free;
+ }
}
/** Not yet implemented */