MCPcopy Create free account
hub / github.com/IENT/YUView / systemMemorySizeInMB

Function systemMemorySizeInMB

YUViewLib/src/common/Functions.cpp:60–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60unsigned int systemMemorySizeInMB()
61{
62 static unsigned int memorySizeInMB;
63 if (!memorySizeInMB)
64 {
65 // Fetch size of main memory - assume 2 GB first.
66 // Unfortunately there is no Qt API for doing this so this is platform dependent.
67 memorySizeInMB = 2 << 10;
68#ifdef Q_OS_MAC
69 int mib[2] = {CTL_HW, HW_MEMSIZE};
70 u_int namelen = sizeof(mib) / sizeof(mib[0]);
71 uint64_t size;
72 size_t len = sizeof(size);
73
74 if (sysctl(mib, namelen, &size, &len, NULL, 0) == 0)
75 memorySizeInMB = size >> 20;
76#elif defined Q_OS_UNIX
77 long pages = sysconf(_SC_PHYS_PAGES);
78 long page_size = sysconf(_SC_PAGE_SIZE);
79 memorySizeInMB = (pages * page_size) >> 20;
80#elif defined Q_OS_WIN32
81 MEMORYSTATUSEX status;
82 status.dwLength = sizeof(status);
83 GlobalMemoryStatusEx(&status);
84 memorySizeInMB = status.ullTotalPhys >> 20;
85#endif
86 }
87 return memorySizeInMB;
88}
89
90QStringList getThemeNameList()
91{

Callers 4

SettingsDialogMethod · 0.85
getCacheSizeInMBMethod · 0.85
performanceTestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected