Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sys.free_memory wrong on Apple ARM #47684

Closed
fonsp opened this issue Nov 23, 2022 · 2 comments
Closed

Sys.free_memory wrong on Apple ARM #47684

fonsp opened this issue Nov 23, 2022 · 2 comments
Labels
system:apple silicon Affects Apple Silicon only (Darwin/ARM64) - e.g. M1 and other M-series chips

Comments

@fonsp
Copy link
Member

fonsp commented Nov 23, 2022

On Julia 1.8.3, ARM build, and x86 build with Rosetta, Sys.free_memory() returns around 50MB, while my activity monitor shows that 2.5GB is free. Sys.total_memory() is correct. Note the Memory: line in the screenshot below:

image

The result of Sys.free_memory() is not fixed, but it is always too low:

julia> Sys.free_memory() / 1e9
0.086638592

julia> Sys.free_memory() / 1e9
0.076365824

julia> Sys.free_memory() / 1e9
0.089423872
@brenhinkeller brenhinkeller added the system:mac Affects only macOS label Nov 23, 2022
@giordano giordano added system:apple silicon Affects Apple Silicon only (Darwin/ARM64) - e.g. M1 and other M-series chips and removed system:mac Affects only macOS labels Nov 23, 2022
@vtjnash
Copy link
Member

vtjnash commented Nov 23, 2022

Might need to file this upstream with libuv too, if the issue is accurate. Maybe we should try using host_statistics64 for this API? FWIW, on my Intel machine with 16 GB ram and 12 GB "used" I get:

julia> Sys.free_memory() /1024/1024
143.796875

julia> Sys.free_physical_memory() /1024/1024
187.02734375

julia> Sys.MACHINE
"x86_64-apple-darwin21.6.0"

due to host_statistics(HOST_VM_INFO) reporting:

(vm_statistics_data_t) $0 = {
  free_count = 18330
  active_count = 1389516
  inactive_count = 1380917
  wire_count = 786126
  zero_fill_count = 479466944
  reactivations = 18148299
  pageins = 17841460
  pageouts = 247405
  faults = 878748845
  cow_faults = 11088343
  lookups = 0
  hits = 0
  purgeable_count = 184555
  purges = 9635737
  speculative_count = 12151
}

It is also thus likely that this value is correct, and that there are various file caches occupying the difference in space. Which is both "free" (in the sense that it can be dropped without writing to cache) and used (in the sense that it currently is allocated to hold something)

htop reports

  Mem[7.91G/16.0G] Swp[2.53G/4.00G] 

top reports

MemRegions: 164057 total, 5193M resident, 157M private, 1315M shared.
PhysMem: 15G used (3112M wired), 823M unused.

@vtjnash
Copy link
Member

vtjnash commented Feb 10, 2024

It looks like this value is correct (as reported by the kernel). It may not be useful to you, but then, this function probably isn't useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:apple silicon Affects Apple Silicon only (Darwin/ARM64) - e.g. M1 and other M-series chips
Projects
None yet
Development

No branches or pull requests

4 participants