| 350 | } |
| 351 | |
| 352 | int64_t System::RamFree() |
| 353 | { |
| 354 | #if defined(__APPLE__) |
| 355 | mach_port_t host_port = mach_host_self(); |
| 356 | if (host_port == MACH_PORT_NULL) |
| 357 | return -1; |
| 358 | |
| 359 | vm_size_t page_size = 0; |
| 360 | host_page_size(host_port, &page_size); |
| 361 | |
| 362 | vm_statistics_data_t vmstat; |
| 363 | mach_msg_type_number_t count = HOST_VM_INFO_COUNT; |
| 364 | kern_return_t kernReturn = host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vmstat, &count); |
| 365 | if (kernReturn != KERN_SUCCESS) |
| 366 | return -1; |
| 367 | |
| 368 | [[maybe_unused]] int64_t used_mem = (vmstat.active_count + vmstat.inactive_count + vmstat.wire_count) * page_size; |
| 369 | int64_t free_mem = vmstat.free_count * page_size; |
| 370 | return free_mem; |
| 371 | #elif defined(unix) || defined(__unix) || defined(__unix__) |
| 372 | int64_t pages = sysconf(_SC_AVPHYS_PAGES); |
| 373 | int64_t page_size = sysconf(_SC_PAGESIZE); |
| 374 | if ((pages > 0) && (page_size > 0)) |
| 375 | return pages * page_size; |
| 376 | |
| 377 | return -1; |
| 378 | #elif defined(_WIN32) || defined(_WIN64) |
| 379 | MEMORYSTATUSEX status; |
| 380 | status.dwLength = sizeof(status); |
| 381 | GlobalMemoryStatusEx(&status); |
| 382 | return status.ullAvailPhys; |
| 383 | #else |
| 384 | #error Unsupported platform |
| 385 | #endif |
| 386 | } |
| 387 | |
| 388 | uint64_t System::CurrentThreadId() |
| 389 | { |
nothing calls this directly
no outgoing calls
no test coverage detected