diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-11-30 22:06:01 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 22:06:01 +0900 |
commit | 3591ba8578b5eff96c13afc6fdfcf95a96083761 (patch) | |
tree | 087723f0e357df08e6254a440749a53b5c588444 /ext/node/polyfills/os.ts | |
parent | 595a2be024b3523197557a8b122e3ce77f1dae3c (diff) |
fix(ext/node): fix os.freemem (#21347)
Diffstat (limited to 'ext/node/polyfills/os.ts')
-rw-r--r-- | ext/node/polyfills/os.ts | 9 |
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 */ |