简体   繁体   中英

Swift/iOS - Massive memory usage attributed to "__StringStorage"?

I'm seeing huge memory usage in my app (almost a gig)

I profiled my app by generating and exporting a Memory Graph and ran

heap -s --showSizes my_memgraph.memgraph

I'm seeing hundreds of megabytes attributed to __StringStorage

    COUNT     BYTES       AVG   CLASS_NAME                                       TYPE    BINARY
    =====     =====       ===   ==========                                       ====    ======
       56      3584      64.0   __StringStorage                                  Swift   libswiftCore.dylib
    47279   3782320      80.0   __StringStorage                                  Swift   libswiftCore.dylib
       61      5856      96.0   __StringStorage                                  Swift   libswiftCore.dylib
        6       672     112.0   __StringStorage                                  Swift   libswiftCore.dylib
    21021   2690688     128.0   __StringStorage                                  Swift   libswiftCore.dylib
     1008    145152     144.0   __StringStorage                                  Swift   libswiftCore.dylib
    19030   3044800     160.0   __StringStorage                                  Swift   libswiftCore.dylib
        1       192     192.0   __StringStorage                                  Swift   libswiftCore.dylib
     6000   1536000     256.0   __StringStorage                                  Swift   libswiftCore.dylib
        5     12800    2560.0   __StringStorage                                  Swift   libswiftCore.dylib
     7052 231079936   32768.0   __StringStorage                                  Swift   libswiftCore.dylib
     7000 344064000   49152.0   __StringStorage                                  Swift   libswiftCore.dylib
   292889   4686224      16.0   non-object                                                                 
    92169   2949408      32.0   non-object                                                                 
    54659   2623632      48.0   non-object                                                                 
    72672   4651008      64.0   non-object                    

What is that and what can I do about it?

I figured it out, I found the libswiftCore in the memgraph gui and clicking around on the objects noticed that nearly all of them were retained by GraphQL.

Changing the graphQL cache policy from .fetchIgnoringCacheData to .fetchIgnoringCacheCompletely made my problem go away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM