Fix free memory calculation.

https://codereview.chromium.org/2558043007
This commit is contained in:
Aleksei Kuzmin 2017-06-28 17:25:07 +02:00
parent 627eb30409
commit f4411889a9

View file

@ -164,7 +164,15 @@ v8::Local<v8::Value> AtomBindings::GetSystemMemoryInfo(v8::Isolate* isolate,
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("total", mem_info.total);
dict.Set("free", mem_info.free);
// See Chromium's "base/process/process_metrics.h" for an explanation.
int free =
#if defined(OS_WIN)
mem_info.avail_phys;
#else
mem_info.free;
#endif
dict.Set("free", free);
// NB: These return bogus values on macOS
#if !defined(OS_MACOSX)