Class ApkAssetsCache

java.lang.Object
org.robolectric.res.android.ApkAssetsCache

public final class ApkAssetsCache extends Object
A global cache for ApkAssets (framework and app resources). This cache is shared between sandboxes to avoid having to store multiple copies of system resources for the same SDK level (i.e. different looper, graphics modes, or instrumentation configuration).

Previously there was a per-sandbox cache for system resources, but with the resource tables growing in size, and an increasing number of sandbox parameters, the memory usage did not scale well as test suites increased in size.

Currently the items in this cache are not made available for GC. However, it would definitely be possible to have a per-sdk-level reference counting mechanism where an item could be freed if all sandboxes referencing that item are collected.

  • Method Details

    • put

      public static void put(String path, boolean system, int apiLevel, long ptr)
    • get

      public static long get(String path, boolean system, int apiLevel)