瀏覽代碼

计算虚拟内存

huzhiqiang 3 年之前
父節點
當前提交
c8734a77de

+ 1 - 0
BFFramework/Classes/BFFramework_custom_umbrella.h

@@ -19,5 +19,6 @@
 #import "UIControl+NXCategory.h"
 #import <TXLiteAVSDK_Player/TXLiteAVSDK.h>
 #import <Bugly/Bugly.h>
+#import "MemoryCoculation.h"
 
 #endif /* AliyunOSSiOS_Bridging_Header */

+ 16 - 0
BFFramework/Classes/BFModules/BFUtility/MemoryCoculation.h

@@ -0,0 +1,16 @@
+//
+//  MemoryCoculation.h
+//  BFFramework
+//
+//  Created by Harry Hu on 2021/10/13.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface MemoryCoculation : NSObject
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 22 - 0
BFFramework/Classes/BFModules/BFUtility/MemoryCoculation.m

@@ -0,0 +1,22 @@
+//
+//  MemoryCoculation.m
+//  BFFramework
+//
+//  Created by Harry Hu on 2021/10/13.
+//
+
+#import "MemoryCoculation.h"
+
+@implementation MemoryCoculation
+
++ (int64_t)memoryResidentSize {
+    struct task_basic_info info;
+//    mach_msg_type_number_t size = sizeof(task_basic_info_data_t) / sizeof(natural_t);
+//    kern_return_t ret = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
+//    if (ret != KERN_SUCCESS) {
+//        return 0;
+//    }
+    return info.resident_size;
+}
+
+@end