Skip to content

Commit

Permalink
Add memory usage to demo
Browse files Browse the repository at this point in the history
  • Loading branch information
kaishin committed Jan 2, 2024
1 parent b2b4ee7 commit 92abae0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Demo/Demo-iOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ class ViewController: UIViewController {
}

class Memory: NSObject {
// From Quinn the Eskimo at Apple.
// https://forums.developer.apple.com/thread/105088#357415

class func memoryFootprint() -> Int? {
// The `TASK_VM_INFO_COUNT` and `TASK_VM_INFO_REV1_COUNT` macros are too
// complex for the Swift C importer, so we have to define them ourselves.
let TASK_VM_INFO_COUNT = mach_msg_type_number_t(MemoryLayout<task_vm_info_data_t>.size / MemoryLayout<integer_t>.size)
let TASK_VM_INFO_REV1_COUNT = mach_msg_type_number_t(MemoryLayout.offset(of: \task_vm_info_data_t.min_address)! / MemoryLayout<integer_t>.size)

Expand Down

0 comments on commit 92abae0

Please sign in to comment.