1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

runtime: add new functions total_memory/0 and free_memory/0 (#18499)

This commit is contained in:
kbkpbot
2023-06-24 19:15:15 +08:00
committed by GitHub
parent 2abd2e2c2a
commit 5f0ad64155
7 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,10 @@
module runtime
fn free_memory_impl() usize {
$if linux {
page_size := usize(C.sysconf(C._SC_PAGESIZE))
av_phys_pages := usize(C.sysconf(C._SC_AVPHYS_PAGES))
return page_size * av_phys_pages
}
return 1
}