54 lines
1.2 KiB
Plaintext
54 lines
1.2 KiB
Plaintext
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "Host/SystemInfo.hpp"
|
|
#include "Base/Logger.hpp"
|
|
#include <mach/mach.h>
|
|
#include <os/proc.h>
|
|
|
|
#import <Foundation/NSProcessInfo.h>
|
|
|
|
namespace openVulkanoCpp
|
|
{
|
|
size_t SystemInfo::GetSystemRam()
|
|
{
|
|
return [NSProcessInfo processInfo].physicalMemory;
|
|
}
|
|
|
|
size_t SystemInfo::GetSystemRamAvailable()
|
|
{
|
|
return os_proc_available_memory();
|
|
}
|
|
|
|
size_t SystemInfo::GetAppRamMax()
|
|
{
|
|
return GetAppRamAvailable() + GetAppRamUsed();
|
|
}
|
|
|
|
size_t SystemInfo::GetAppVirtualMemoryMax()
|
|
{
|
|
return INT64_MAX;
|
|
}
|
|
|
|
size_t SystemInfo::GetAppRamAvailable()
|
|
{
|
|
return os_proc_available_memory();
|
|
}
|
|
|
|
size_t SystemInfo::GetAppRamUsed()
|
|
{
|
|
struct task_basic_info info;
|
|
mach_msg_type_number_t size = sizeof(info);
|
|
kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
|
|
if( kerr == KERN_SUCCESS )
|
|
{
|
|
return info.resident_size;
|
|
}
|
|
Logger::PERF->error("Failed to read memory consumption: {}", mach_error_string(kerr));
|
|
return 0;
|
|
}
|
|
}
|