You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I copied the example for reading system metrics (https://docs.deno.com/examples/reading_system_metrics/) to test it and noticed that Deno.systemMemoryInfo().available and Deno.systemMemoryInfo().free appear to be ~1000x smaller than they should be.
Total Memory: 16384 MB
what Deno.systemMemoryInfo() reports - deno 2.1.4
Free Memory: 0.102996826171875 MB
Available Memory: 4.8754119873046875 MB
Used Memory: 16379.124588012695 MB
corrected for macOS:
Free Memory: 105.46875 MB
Available Memory: 4992.421875 MB
Used Memory: 11391.578125 MB
Deno 2.1.4 Wrong Percentage: 99.97%
macOS Corrected Percentage: 69.53%
The corrected values are more accurate to what I see in macOS Activity Monitor and when running a similar Rust program with the sysinfo crate.
Repro Steps
deno run --allow-sys https://gist.githubusercontent.com/brettchalupa/62e489396ae4cf87ee59517fcc0880c4/raw/34d8cc2908644bd458dec5b4894f6468ba9644e4/deno_ram_check_bug.ts
The text was updated successfully, but these errors were encountered:
brettchalupa
changed the title
Deno.systemMemoryInfo().available and Deno.systemMemoryInfo().free are off by x1024 on macOSDeno.systemMemoryInfo().available and Deno.systemMemoryInfo().free are incorrect on macOS
Dec 20, 2024
Version: Deno 2.1.4
OS: macOS 14.6 (Sonoma)
I copied the example for reading system metrics (https://docs.deno.com/examples/reading_system_metrics/) to test it and noticed that
Deno.systemMemoryInfo().available
andDeno.systemMemoryInfo().free
appear to be ~1000x smaller than they should be.The corrected values are more accurate to what I see in macOS Activity Monitor and when running a similar Rust program with the
sysinfo
crate.Repro Steps
View the Gist source.
Zoom into the problem code and fix for macOS:
I'm not 100% sure whether the multiplication needs to be
* 1024
or* 1000
.Additional Notes
Deno.systemMemoryInfo().available
and.free
are correct on Fedora Linux.available
reports0
, but.free
seems to be correctSee Also
Deno.systemMemoryInfo().available
and(node:os).freemem()
is off by x1000 #25497os.freemem()
pollyfill is not compatible with Node.js #21148The text was updated successfully, but these errors were encountered: