5 Replies
      Latest reply on May 23, 2017 11:22 AM by agart1
      saggymac Level 1 Level 1 (10 points)

        If I download on-demand-resources during an app session, either calling endAccessingResources() or dealloc'ing the triggering NSBundleResourceRequest will mark the content as "surplus to requirements", effectively. That content may be purged.

         

        I'm trying to understand when that would occur.

         

        WWDC'2015 session 214 discusses this at around 32minutes in. They say resource packs are only purged when the system is low on space. They also say that asset packs are selected for deletion based on the time of last usage and preservation priorities.

         

        I didn't hear anything about which apps are examined and in what order. Is it like memory, where the apps are ranked and examined based on highest consumption of apps not presently running first?

         

        Or is it just about the max 2GB of ODR data in use at any given time, so per app?

        • Re: Lifetime of ODR content
          tober79 Level 1 Level 1 (0 points)

          What you say fits into my observations of disk report during debugging. Also, after the user quits the app the ODR status goes to "downloaded", only after you reopen the app and start accessing ODR again it becomes "in use" again.

           

          Is it correct, that ODR may get purged, while the app is not running? That would mean there is no way to make a resource permanent? I.e. if the user has no internet connection and the resource was purged we have a problem?

            • Re: Lifetime of ODR content
              Misterwindupbird Level 1 Level 1 (0 points)

              There's no way to make an ODR permanent.  If you make a resource an ODR it is up to your app to deal with the possibility it has been purged or not yet downloaded and the resource is unavailable (because internet is not available, the server is down, etc).

              • Re: Lifetime of ODR content
                mattn Level 1 Level 1 (10 points)

                Could one, at least in theory, download via ODR and then immediately copy the resources to, say, the Documents folder and then release the ODR copy? - This is a very weird architecture. I just don't get it. Apple gives an example of a game level, but how can this possibly work if the level's resources can vanish at any time?

                  • Re: Lifetime of ODR content
                    agart1 Apple Staff Apple Staff (30 points)

                    Hello,

                     

                    Short answer to your question, yes you could download the ODR content then copy it somewhere else. However, that kind of goes against why ODR was created. The content for ODR is meant to be assets used once, infrequently, temporary, etc. Using the game level example, users rarely go back and replay level 1, or the tutorial, of a game, so, the OS will make sure it's safe to get rid of those assets when the time comes. Specifically, the OS will be smart about when it's purging your assets. If the device needs to free up memory, it will look at ODR content first. However, there are numerous factors taken into consideration when looking at which memory to purge, including app use frequency.

                     

                    - Hope that helps,

                    Alex