JakeWharton/DiskLruCache — pull request #63 by sjudd (2014-06-22 22:17:54+00:00)
Title: Memoize Entry Files to reduce char[] allocations.

While trying to reduce garbage collections in a sample app, I noticed that this library allocates a couple of strings per request (once for the file name, and once to join the directory and the file name) which generates enough garbage to cause gcs to noticeably increase in frequency.

The largest strings I saw were around 300 characters so the memory overhead of holding on to the files for each entry is probably pretty small. Even with 5000 entries in memory at once the total overhead would be less than 3mb (300 characters * 2 bytes per character * 5000 entries). At the same time even with only a few items per row, scrolling a list could easily generate a couple of kB worth of garbage per row.