Add MemoryUtil for Apple external.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
package funkin.external.apple;
|
||||
|
||||
#if (ios || macos)
|
||||
#if ((ios || macos) && cpp)
|
||||
/**
|
||||
* A utility class to manage the audio session on apple devices.
|
||||
*/
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package funkin.external.apple;
|
||||
|
||||
#if ((ios || macos) && cpp)
|
||||
/**
|
||||
* A utility class to get information about the mem usage.
|
||||
*/
|
||||
@:build(funkin.util.macro.LinkerMacro.xml('project/Build.xml'))
|
||||
@:include('MemoryUtil.hpp')
|
||||
@:unreflective
|
||||
extern class MemoryUtil
|
||||
{
|
||||
/**
|
||||
* Retrieves the current process's resident set size (RSS) in bytes on Apple platforms.
|
||||
*
|
||||
* @return The resident set size (RSS) in bytes if successful; otherwise, returns 0 on failure.
|
||||
*/
|
||||
@:native('Apple_MemoryUtil_GetCurrentProcessRss')
|
||||
static function getCurrentProcessRss():cpp.SizeT;
|
||||
}
|
||||
#end
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package funkin.external.apple;
|
||||
|
||||
#if (ios || macos)
|
||||
#if ((ios || macos) && cpp)
|
||||
/**
|
||||
* A utility class to get screen related informations on apple devices.
|
||||
*/
|
||||
|
||||
+2
-1
@@ -13,8 +13,9 @@
|
||||
<files id="external-apple">
|
||||
<compilerflag value="-I${this_dir}/include" />
|
||||
|
||||
<file name="${this_dir}/src/ScreenUtil.mm" />
|
||||
<file name="${this_dir}/src/AudioSession.mm" />
|
||||
<file name="${this_dir}/src/MemoryUtil.mm" />
|
||||
<file name="${this_dir}/src/ScreenUtil.mm" />
|
||||
</files>
|
||||
|
||||
<target id="haxe">
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Retrieves the current process's resident set size (RSS) in bytes on Apple platforms.
|
||||
*
|
||||
* @return The resident set size (RSS) in bytes if successful; otherwise, returns 0 on failure.
|
||||
*/
|
||||
size_t Apple_MemoryUtil_GetCurrentProcessRss();
|
||||
@@ -0,0 +1,13 @@
|
||||
#import "MemoryUtil.hpp"
|
||||
|
||||
#include <mach/mach.h>
|
||||
|
||||
size_t Apple_MemoryUtil_GetCurrentProcessRss()
|
||||
{
|
||||
task_basic_info info;
|
||||
|
||||
if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &TASK_BASIC_INFO_COUNT) != KERN_SUCCESS)
|
||||
return 0;
|
||||
|
||||
return info.resident_size;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class MemoryUtil
|
||||
|
||||
public static function supportsTaskMem():Bool
|
||||
{
|
||||
#if ((windows && cpp) || linux || android)
|
||||
#if ((cpp && (windows || ios || macos)) || linux || android)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@@ -58,6 +58,8 @@ class MemoryUtil
|
||||
{
|
||||
#if (windows && cpp)
|
||||
return funkin.external.windows.WinAPI.getProcessMemoryWorkingSetSize();
|
||||
#elseif ((ios || macos) && cpp)
|
||||
return funkin.external.apple.MemoryUtil.getCurrentProcessRss();
|
||||
#elseif (linux || android)
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user