vmmap REGION TYPE 在 SwiftUI Image 中没有“Image IO”?

问题描述

我正在我的 SwiftUI 视图中搜索实际的图像内存。

我查看了这篇文章“https://www.swiftjectivec.com/optimizing-images/”

问题是我的 memgraph 区域 tyoe 中没有“Image IO”名称

SwiftUI 使用与 UIKit 不同的机制吗?

我猜 CoreAnimation 可能与 Image IO 相同,因为我听说 SwiftUI 使用 Metal 或没关系

REGION TYPE                        SIZE     SIZE     SIZE     SIZE     SIZE     SIZE     SIZE    COUNT (non-coalesced) 
===========                     ======= ========    =====  ======= ========   ======    =====  ======= 
Activity Tracing                   256K      32K      32K       0K       0K      32K       0K        1 
CoreAnimation                     12.9M    12.9M    12.9M       0K       0K       0K       0K        2 
Foundation                          16K      16K      16K       0K       0K       0K       0K        1 
IOKit                               16K      16K      16K       0K       0K       0K       0K        1 
Kernel Alloc Once                   32K      16K      16K       0K       0K       0K       0K        1 
MALLOC guard page                  128K       0K       0K       0K       0K       0K       0K        8 
MALLOC Metadata                    240K     224K     224K       0K       0K       0K       0K       11 
MALLOC_LARGE                       704K     704K     704K       0K       0K       0K       0K        7         see MALLOC ZONE table below
MALLOC_LARGE Metadata               16K      16K      16K       0K       0K       0K       0K        1         see MALLOC ZONE table below
MALLOC_NANO                      512.0M    2320K    2304K       0K       0K       0K       0K        1         see MALLOC ZONE table below
MALLOC_SMALL                      40.0M     560K     560K       0K       0K       0K       0K        5         see MALLOC ZONE table below
MALLOC_SMALL (empty)              16.0M      80K      80K       0K       0K       0K       0K        2         see MALLOC ZONE table below
MALLOC_TINY                       9216K     368K     368K       0K       0K       0K       0K        9         see MALLOC ZONE table below
MALLOC_TINY (empty)               1024K      32K      32K       0K       0K       0K       0K        1         see MALLOC ZONE table below
Performance tool data              336K     336K     336K       0K       0K       0K       0K        4         not counted in TOTAL below
STACK GUARD                         48K       0K       0K       0K       0K       0K       0K        3 
Stack                             2096K     128K     112K       0K       0K       0K       0K        3 
Stack (reserved)                   544K       0K       0K       0K       0K       0K       0K        1         reserved VM address space (unallocated)
Stack Guard                         16K       0K       0K       0K       0K       0K       0K        1 
VM_ALLOCATE                       1280K      96K      96K       0K       0K       0K       0K        5 
VM_ALLOCATE (reserved)              16K       0K       0K       0K       0K       0K       0K        1         reserved VM address space (unallocated)
__AUTH                            2158K    2095K     346K       0K       0K       0K       0K      293 
__AUTH_CONST                      16.2M    9732K    2902K       0K       0K       0K       0K      417 
__DATA                            11.8M    6899K    1674K       0K       0K       0K       0K      412 
__DATA_CONST                      15.2M    10.1M    2597K       0K       0K       0K       0K      425 
__data_dirTY                      1680K    1309K     746K       0K       0K       0K       0K      346 
__FONT_DATA                          4K       0K       0K       0K       0K       0K       0K        1 
__LINKEDIT                       152.0M    24.9M       0K       0K       0K       0K       0K       16 
__OBJC_CONST                      3294K    3294K     965K       0K       0K       0K       0K      264 
__OBJC_RO                         71.2M    50.6M       0K       0K       0K       0K       0K        1 
__OBJC_RW                         2896K    1708K      12K       0K       0K       0K       0K        1 
__TEXT                           396.2M   192.5M      96K       0K       0K       0K       0K      445 
__UNICODE                          588K     576K       0K       0K       0K       0K       0K        1 
mapped file                       38.3M    6224K      48K       0K       0K       0K       0K        5 
shared memory                      192K      64K      64K       0K       0K      16K       0K        4 
unused but dirty shlib __DATA     86.3M    32.6M    24.3M       0K       0K       0K       0K      778 
===========                     ======= ========    =====  ======= ========   ======    =====  ======= 
TOTAL                              1.4G   359.2M    50.9M       0K       0K      48K       0K     3474 
TOTAL,minus reserved VM space     1.4G   359.2M    50.9M       0K       0K      48K       0K     3474 

                                 VIRTUAL   RESIDENT      DIRTY    SWAPPED ALLOCATION      BYTES DIRTY+SWAP          REGION
MALLOC ZONE                         SIZE       SIZE       SIZE       SIZE      COUNT  ALLOCATED  FRAG SIZE  % FRAG   COUNT
===========                      =======  =========  =========  =========  =========  =========  =========  ======  ======
DefaultMallocZone_0x1005f8000     512.0M      2320K      2304K         0K      21657      1151K      1153K     51%       1
MallocHelperZone_0x1005f0000       54.7M      1600K      1600K         0K        379      1078K       522K     33%      20
QuartzCore_0x100ac0000             12.0M       160K       160K         0K        175        20K       140K     88%       5
===========                      =======  =========  =========  =========  =========  =========  =========  ======  ======
TOTAL                             578.7M      4080K      4064K         0K      22211      2249K      1815K     45%      26

这是这个单图应用的表情包

import SwiftUI

struct ContentView: View {
    var body: some View {
        Image(uiImage: fetchImage())
//            .resizable()
//            .frame(width: 92,height: 118,alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
    }
    
    func fetchImage() -> UIImage {
        let filePath = Bundle.main.path(forResource: "testimage",ofType: "png")!
        _ = NSURL(fileURLWithPath: filePath)
        let fileImage = UIImage(contentsOfFile: filePath)
        return fileImage!
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

如何找到这张单张图片的实际内存?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)