Rather than unloading resources immediately when unused, use a simple LRU cache.