Windows and Linux builds: Physical and available system memory are now reported in the log header.
This commit is contained in:
parent
a3fbbe7e07
commit
f0a01c7753
@ -27,6 +27,10 @@ MA 02110-1301, USA.
|
|||||||
#import "OOCocoa.h"
|
#import "OOCocoa.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#if OOLITE_LINUX
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void OOCPUInfoInit(void);
|
void OOCPUInfoInit(void);
|
||||||
|
|
||||||
@ -43,6 +47,13 @@ NSUInteger OOCPUCount(void);
|
|||||||
#if (OOLITE_WINDOWS || OOLITE_LINUX)
|
#if (OOLITE_WINDOWS || OOLITE_LINUX)
|
||||||
NSString* OOCPUDescription(void);
|
NSString* OOCPUDescription(void);
|
||||||
void OOCPUID(int CPUInfo[4], int InfoType);
|
void OOCPUID(int CPUInfo[4], int InfoType);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned long long ooPhysicalMemory;
|
||||||
|
unsigned long long ooAvailableMemory;
|
||||||
|
} OOMemoryStatus;
|
||||||
|
OOMemoryStatus OOSystemMemoryStatus(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,6 +154,33 @@ NSString* OOCPUDescription(void)
|
|||||||
}
|
}
|
||||||
return [NSString stringWithCString:CPUBrandString];
|
return [NSString stringWithCString:CPUBrandString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OOMemoryStatus OOSystemMemoryStatus(void)
|
||||||
|
{
|
||||||
|
const unsigned int toMegabyte = 1024 * 1024;
|
||||||
|
|
||||||
|
OOMemoryStatus systemMemoryStatus;
|
||||||
|
memset(&systemMemoryStatus, 0, sizeof(systemMemoryStatus));
|
||||||
|
|
||||||
|
#if OOLITE_WINDOWS
|
||||||
|
MEMORYSTATUSEX memStatus;
|
||||||
|
memStatus.dwLength = sizeof(memStatus);
|
||||||
|
if(GlobalMemoryStatusEx(&memStatus))
|
||||||
|
{
|
||||||
|
// return memory size in MB
|
||||||
|
systemMemoryStatus.ooPhysicalMemory = memStatus.ullTotalPhys / toMegabyte;
|
||||||
|
systemMemoryStatus.ooAvailableMemory = memStatus.ullAvailPhys / toMegabyte;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
struct sysinfo si;
|
||||||
|
sysinfo(&si);
|
||||||
|
systemMemoryStatus.ooPhysicalMemory = (unsigned long long)(si.totalram / toMegabyte);
|
||||||
|
systemMemoryStatus.ooAvailableMemory = (unsigned long long)(si.freeram / toMegabyte);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return systemMemoryStatus;
|
||||||
|
}
|
||||||
#endif //(OOLITE_WINDOWS || OOLITE_LINUX)
|
#endif //(OOLITE_WINDOWS || OOLITE_LINUX)
|
||||||
|
|
||||||
|
|
||||||
|
@ -348,7 +348,8 @@ static NSString *AdditionalLogHeaderInfo(void)
|
|||||||
{
|
{
|
||||||
unsigned cpuCount = OOCPUCount();
|
unsigned cpuCount = OOCPUCount();
|
||||||
NSString *cpuDescription = OOCPUDescription();
|
NSString *cpuDescription = OOCPUDescription();
|
||||||
|
OOMemoryStatus systemMemoryStatus = OOSystemMemoryStatus();
|
||||||
|
|
||||||
return [NSString stringWithFormat:@"%@ %u processor%@ detected.", cpuDescription, cpuCount, cpuCount != 1 ? @"s" : @""];
|
return [NSString stringWithFormat:@"%@ %u processor%@ detected. System RAM: %llu MB (free: %llu MB).", cpuDescription, cpuCount, cpuCount != 1 ? @"s" : @"", systemMemoryStatus.ooPhysicalMemory, systemMemoryStatus.ooAvailableMemory];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user