| 270 | } |
| 271 | |
| 272 | size_t NSystemInfo::TotalMemorySize() { |
| 273 | #if defined(_linux_) && defined(_64_) |
| 274 | try { |
| 275 | auto q = FromString<size_t>(StripString(TFileInput("/sys/fs/cgroup/memory/memory.limit_in_bytes").ReadAll())); |
| 276 | |
| 277 | if (q < (((size_t)1) << 60)) { |
| 278 | return q; |
| 279 | } |
| 280 | } catch (...) { |
| 281 | } |
| 282 | #endif |
| 283 | |
| 284 | #if defined(_linux_) || defined(_cygwin_) |
| 285 | struct sysinfo info; |
| 286 | sysinfo(&info); |
| 287 | return info.totalram; |
| 288 | #elif defined(_darwin_) |
| 289 | int mib[2]; |
| 290 | int64_t memSize; |
| 291 | size_t length; |
| 292 | |
| 293 | // Get the Physical memory size |
| 294 | mib[0] = CTL_HW; |
| 295 | mib[1] = HW_MEMSIZE; |
| 296 | length = sizeof(int64_t); |
| 297 | if (sysctl(mib, 2, &memSize, &length, NULL, 0) != 0) { |
| 298 | ythrow yexception() << "sysctl failed: " << LastSystemErrorText(); |
| 299 | } |
| 300 | return (size_t)memSize; |
| 301 | #elif defined(_win_) |
| 302 | MEMORYSTATUSEX memoryStatusEx; |
| 303 | memoryStatusEx.dwLength = sizeof(memoryStatusEx); |
| 304 | if (!GlobalMemoryStatusEx(&memoryStatusEx)) { |
| 305 | ythrow yexception() << "GlobalMemoryStatusEx failed: " << LastSystemErrorText(); |
| 306 | } |
| 307 | return (size_t)memoryStatusEx.ullTotalPhys; |
| 308 | #else |
| 309 | return 0; |
| 310 | #endif |
| 311 | } |
| 312 | |
| 313 | size_t NSystemInfo::MaxOpenFiles() { |
| 314 | #if defined(ANDROID) || defined(__ANDROID__) |
nothing calls this directly
no test coverage detected