Page MenuHomePhabricator

Set threshold on shared image cache to limit number of images stored in memory.
Closed, ResolvedPublic

Description

Result of performance spike T124331

As a low-hanging fruit, we decided to set a naive limit on the count of images stored in memory. Although NSCache doesn't guarantee when (if ever) it will purge objects from memory when thresholds are exceeded, this should (at least in theory) prevent image usage in the app from causing memory warnings as often as they currently do.

Acceptance criteria

  • Set a limit on WMFImageController's internal memory cache (SDImageCache.maxMemoryCountLimit)
  • Test the app to see if count limits are respected by the cache
  • Verify that operating the app with the cache near its count limit doesn't cause excessive "thrashing" of the cache repeatedly purging and re-storing the same images (i.e. should purge in LRU order)

Event Timeline

Acceptance Criteria are technical... I'd say up to an Engineer to verify/close.

I can see the code that changed it, unfortunately I'm not seeing a large difference in memory usage. NSCache (infamously) omits any guarantee that it will evict objects once the count limit is exceeded. And after browsing many POTD and several articles, I should have easily hit 50 images and started to see things level off. Resolving that the work was done, but it's unclear if there was any significant improvement.