spotify / spotify/SPTPersistentCache
Scheduling of garbage collection
Nobody has claimed this yet.
- Dominant language
- Objective-C
- Stars
- 1.2k
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing SPTPersistentCache's existing garbage-collection scheduling behavior and how it is unscheduled when the app enters the background. Determine how a caller could trigger one background cleanup reliably, and consider the issue resolved when that manual cleanup path is defined and its scheduling and cancellation behavior is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100