8 Replies
      Latest reply on May 31, 2019 10:09 AM by destryST
      funcoder Level 1 Level 1 (0 points)

        Hi all,

        I appreciate your help with this problem, I'm really stuck.

         

        One of my beta testers reports frequent crashes of my app. The iOS log reports:

         

        Apr 15 23:52:14 iPhone SpringBoard[58] <Warning>: Application 'UIKitApplication:de.loffler.XBMCMusicRemotePro[0x553a]' was killed by jetsam.
        Apr 15 23:52:14 iPhone UserEventAgent[26] <Warning>: 440891049998: id=de.loffler.XBMCMusicRemotePro pid=1518, state=0
        
        
        

         

        So the app was killed because of a low memory condition. Usually, I'd know what do do (look for leaks etc), however, there are some issues that are really strange:

         

        1. Low memory usage

         

        According to the JetsamEvent.ips, the memory usage of my app is just 32MB (if I interpret the report correctly: 2050 resident pages * 16384 page size). The tester has an iPhone 6S with 2GB of RAM, so at the point of the crash, the app uses no more than 2% of the entire memory of the device. Additionally, if I sum up the "rpages" of all entries in the report, I'm just getting ca. 620MB of usage. Maybe I'm having some misunderstandings reading the report...

         

        I wrote a test function that just consumes memory until the app is killed. When running this function on my iPhone 5S, the app only gets killed by the time it reaches 600MB memory usage.

         

        {"timestamp":"2016-04-15 23:52:13.13 +0200","bug_type":"298","os_version":"iPhone OS 9.3 (13E234)"}
        {
        "crashReporterKey" : "bec1fa98267fbf2d761102140fcf61aa7b6b5e25",
        "kernel" : "Darwin Kernel Version 15.4.0: Fri Feb 19 13:54:52 PST 2016; root:xnu-3248.41.4~28\/RELEASE_ARM64_S8000",
        "product" : "iPhone8,1",
        "incident" : "A2B3C5FF-8ECC-4E07-BEDA-E847061F396B",
        "date" : "2016-04-15 23:52:13.13 +0200",
        "build" : "iPhone OS 9.3 (13E234)",
        "timeDelta" : 1739,
        "memoryStatus" : {
        "compressorSize" : 76679,
        "pageSize" : 16384,
        "compressions" : 2526427,
        "memoryPages" : {
           "active" : 24493,
           "throttled" : 0,
           "fileBacked" : 24113,
           "wired" : 13007,
           "anonymous" : 12915,
           "purgeable" : 127,
           "inactive" : 10955,
           "free" : 2290,
           "speculative" : 1580
        },
        "uncompressed" : 125795,
        "decompressions" : 143684
        },
        "largestProcess" : "Facebook",
        "processes" : [
        {
        ...
        {
           "rpages" : 2050,
           "states" : [
             "frontmost",
             "resume"
           ],
           "name" : "KodiMusicRemoteP",
           "pid" : 1518,
           "reason" : "vm-thrashing",
           "fds" : 50,
           "uuid" : "5103a88a-917f-319e-8553-c0189dd1abac",
           "purgeable" : 127,
           "cpuTime" : 4.619693,
           "lifetimeMax" : 3557
        },
        ...
        }
        
        
        

         

        2. No memory warnings

         

        I'm writing low memory warnings to a log file (via Cocoa Lumberjack), but in my tester's log I cannot find any such log output. I tested the code with my test function, and it worked fine.

         

        - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
        {
            DDLogError(@"applicationDidReceiveMemoryWarning");
            [DDLog flushLog];
        
            // ... (do some other stuff, release memory)
        }
        
        
        

         

        3. Not seen anywhere else

         

        Noone of the other ten beta testers reported this problem, and I haven't seen it myself with my iPhone 5S, which has half of the memory of the 6S.

         

        4. No typical memory crash scenario

         

        My tester reported that the app sometimes runs fine for some time, but when it crashes and he restarts it, it often crashes quickly again (like after 10s). Based on the architecture of my app, I don't see how a memory leak could cause a behaviour like this.

         

        Thanks for your ideas,

        Markus

        • Re: Strange Jetsam/Low-Memory Crash
          iosdev98278 Level 1 Level 1 (0 points)

          I have the same problem in my app in iOS 10 on iPhone 6 and 6 Plus.

          It seems to me that the problem does not exist in iOS 9.

           

          The crash is not reproducable, it appears in various situations when the app is used for some time.

          I used Instruments with Allocations and VM Tracker, but I cannot see any suspicious values or behaviour there.

           

          So I also would be very grateful for ideas and hints from the community,

          since this really a big problem which makes the app not usable anymore.

           

          Thanks,

          Frank

            • Re: Strange Jetsam/Low-Memory Crash
              funcoder Level 1 Level 1 (0 points)

              Hi Frank,

              my problem was not related to iOS 10, so yours might be something different.

               

              If found out that at some point in my app, I was allocating lots of cache memory for images (using SDWebImage lib). At the same time, I blocked the main loop, that's why I didn't get memory warnings and didn't clean up the cache.

               

              One thing I still don't understand is why the Jetsam report doesn't show a high memory usage

              Regards,

              Markus

            • Re: Strange Jetsam/Low-Memory Crash
              kaynn Level 1 Level 1 (0 points)
              "reason" : "vm-thrashing", 
              

               

              this is the reason for your crash. if you google this, you'll find it's because the os is swapping too much pages.

               

              why does this happen? I have no idea.

              • Re: Strange Jetsam/Low-Memory Crash
                AvDev Level 1 Level 1 (0 points)

                Hi,

                 

                I have a problem related to jetSam event and want to post here a new question.

                can anyone guide me plaese how to post a new question? All i can do for now is by replying another one

                 

                thank you

                • Re: Strange Jetsam/Low-Memory Crash
                  jcurless Apple Staff Apple Staff (0 points)

                  Hi,

                   

                  1) So VM-Thrashing means there was a lot of memory being used, and the device needed to clean out a bunch to make sure apps and other system services can still run.  Most likely there is an app using a large amount of memory which is causing this issue.  It appears that it isn't your app as you are using 2050 rpages, which is around 32 MB of memory, not too much for an app.  If you are in the background perhaps you could drop your view hierarchy to save memory.

                  I'd take a look at the log to see what other apps are using a lot of memory.

                   

                  2) Memory warnings are best effort, so you won't necessarily get them when the system needs memory right away.

                   

                  3) Since this most likely isn't caused by your app, I suggest you see what else is running on this one person's device.

                   

                  4) Once again, this is most likely some other app on the device taking up lots of memory, so it wouldn't be reproducible by doing things in your app.

                    • Re: Strange Jetsam/Low-Memory Crash
                      funcoder Level 1 Level 1 (0 points)

                      Hi jcurless,

                      thanks for your reply. Since I did find a memory problem in the app (see my post above on Oct 11) that made these crashes go away, I think it was related to my app. I can send you the full jetsam report if you want, is there a way to send you a private message or attach it somehow, it's rather long.

                      Best regards,

                      Markus

                    • Re: Strange Jetsam/Low-Memory Crash
                      destryST Level 1 Level 1 (0 points)

                      This other thread helped me considerably: https://forums.developer.apple.com/message/346542#346542