Skip to content

Commit

Permalink
Merge pull request #2099 from karelrooted/fix-tvos-memory-size
Browse files Browse the repository at this point in the history
Fix system memory size of tvOS
  • Loading branch information
billhollings authored Dec 19, 2023
2 parents 971096d + d483d62 commit 9fbf8a1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Common/MVKOSExtensions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <mach/mach_time.h>
#include <mach/task.h>
#include <os/proc.h>
#include <sys/sysctl.h>

#import <Foundation/Foundation.h>

Expand Down Expand Up @@ -100,17 +101,12 @@ bool mvkGetEnvVar(const char* varName, string& evStr) {
#pragma mark System memory

uint64_t mvkGetSystemMemorySize() {
#if MVK_MACOS_OR_IOS_OR_VISIONOS
mach_msg_type_number_t host_size = HOST_BASIC_INFO_COUNT;
host_basic_info_data_t info;
if (host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&info, &host_size) == KERN_SUCCESS) {
return info.max_mem;
uint64_t host_memsize = 0;
size_t size = sizeof(host_memsize);
if (sysctlbyname("hw.memsize", &host_memsize, &size, NULL, 0) == KERN_SUCCESS) {
return host_memsize;
}
return 0;
#endif
#if MVK_TVOS
return 0;
#endif
}

uint64_t mvkGetAvailableMemorySize() {
Expand Down

0 comments on commit 9fbf8a1

Please sign in to comment.