-
Notifications
You must be signed in to change notification settings - Fork 76
Description
I'm considering how to schedule the garbage collector for an app that does not have long sessions. I understand that the current way of scheduling works fine for Spotify, since your app will be long running in the background.
Do you guys have any suggestions on how to handle scheduling in an app where the average user session is around 20 seconds? Scheduling it to run every 10 seconds seems unnecessary, but scheduling it to run at > 20 seconds could mean that the GC never runs for some users (since we need to unschedule when the app enters the background, to avoid an NSTimer keeping the app awake).
I think ideally, SPTPersistentCache should have a way to manually start the GC instead of scheduling it. This would allow us to run it once when the app enters background before it gets terminated.
I could achieve this in the current way by scheduling it at 0 seconds when the app enters background, and then immediately unscheduling it. This seems kind of insecure though, since it could run 10 times or even cancel before it runs at all.
Any input is appreciated!