6 Replies
      Latest reply: Mar 5, 2017 2:24 PM by eskimo RSS
      AvDev Level 1 Level 1 (0 points)

        Hi,

         

         

        I have an app connected to a peripheral and as such running in the background. Sometimes when there is a low memory situation, jetSam decides to close my app even though according to the jetSam log it is not the largest running process. So far my app didn't get any memory warnings so it is not even possible to respond to such event by releasing resources.

         

         

        First I would like to know if there are any criteria for closing an app due to a low memory event

        Second, what are the keys in the log? for example the state key - does it represent the current state of the process, i.e. when it is suspended, it means that the app was closed by jetSam?

        Can several processes be closed? Because when I look at all JSONs, only one process has the killDelta key, and it doesn't always happen to be the largest one, and even so I can see that several processes are suspended, meaning again that not only one was closed?

         

         

        thanks in advence

        • Re: jetsam criteria for closing an app
          eskimo Apple Staff Apple Staff (6,075 points)

          The exact algorithms used by jetsam are not documented and change from release to release.  However, you shouldn’t expect jetsam to always terminate the most memory intensive process.  Jetsam will try to avoid terminating the foreground process because that has user-visible consequences.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: jetsam criteria for closing an app
              AvDev Level 1 Level 1 (0 points)

              Thanks for the answer

               

              eventhough we are not exposed to jetsam's algorithms themselves i would be glad for some information about the keys in the jetsam log.

               

              For example the state key which is an array - does it represent the current stae of the app after a jetsam event or it is a value set in the plist for the ios to decide if the app should run in the background? what does "bluetooth" state mean? What does it mean that my app's state is set to "bluetooth" in most jetsam logs but in one case it was set to "suspended"? the killDelta is actually the ExitTimeOut key for which i can set a value in the plist? Is it shown in the log only for the process which was closed by jetsam? (i guess that if yes, then because it is the only process this data is relevant for).

               

              As far as i understand the "purgable" key represent the memory amount which could have been purged from the RAM for the process, so should i expect the process which has the highest value to be closed since it is the worst memory citizen?

               

              One last question - looking at the jetsam log i see no hint that my app was also closed, i can see that SpringBoard was closed and maybe other processes in the state of suspended if this is their current state (my app's state according to jetsam log is "bluetooth"). After 1.6 seconds i can see in my app's log that it crashed, does it mean that for the moment the jetsm log was created my app was still running, but 1.6 seconds after that it was also closed and a new jetsam log file wasn't created because of proximity of events (by event i mean jetsam sending kill to a process)?

               

              Thank you very much