Skip to content

Commit c0c431c

Browse files
ggml-cpu: fix reported free memory
1 parent 186415d commit c0c431c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ggml/src/ggml-cpu/ggml-cpu.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,14 @@ static void ggml_backend_cpu_device_get_memory(ggml_backend_dev_t dev, size_t *
343343
status.dwLength = sizeof(status);
344344
GlobalMemoryStatusEx(&status);
345345
*total = status.ullTotalPhys;
346-
*free = status.ullAvailPhys;
346+
*free = status.ullAvailPhys;
347347
#else
348-
long pages = sysconf(_SC_PHYS_PAGES);
349-
long page_size = sysconf(_SC_PAGE_SIZE);
350-
*total = pages * page_size;
351-
*free = *total;
352-
#endif
348+
const long pages_total = sysconf(_SC_PHYS_PAGES);
349+
const long pages_free = sysconf(_SC_AVPHYS_PAGES);
350+
const long page_size = sysconf(_SC_PAGE_SIZE);
351+
*total = pages_total * page_size;
352+
*free = pages_free * page_size;
353+
#endif // _WIN32
353354

354355
GGML_UNUSED(dev);
355356
}

0 commit comments

Comments
 (0)