/// <summary> /// Modify the configuration of the window cache. /// <para /> /// The new configuration is applied immediately. If the new limits are /// smaller than what what is currently cached, older entries will be purged /// as soon as possible to allow the cache to meet the new limit. /// </summary> /// <param name="cfg"> /// The new window cache configuration. /// </param> public static void reconfigure(WindowCacheConfig cfg) { var newCache = new WindowCache(cfg); WindowCache oldCache = _cache; if (oldCache != null) { oldCache.removeAll(); } _cache = newCache; UnpackedObjectCache.Reconfigure(cfg); }
/// <summary> /// Close the resources utilized by this repository. /// </summary> public void Close() { UnpackedObjectCache.purge(this); WindowCache.Purge(this); lock (locker) { _loadedIdx = null; _reverseIdx = null; } #if DEBUG GC.SuppressFinalize(this); // Disarm lock-release checker #endif }
private void Pin(PackFile pack, long position) { ByteWindow w = _byteWindow; if (w == null || !w.contains(pack, position)) { // If memory is low, we may need what is in our window field to // be cleaned up by the GC during the get for the next window. // So we always clear it, even though we are just going to set // it again. // _byteWindow = null; _byteWindow = WindowCache.get(pack, position); } }
public static ByteWindow get(PackFile pack, long offset) { WindowCache c = _cache; ByteWindow r = c.getOrLoad(pack, c.ToStart(offset)); if (c != _cache) { // The cache was reconfigured while we were using the old one // to load this window. The window is still valid, but our // cache may think its still live. Ensure the window is removed // from the old cache so resources can be released. // c.removeAll(); } return(r); }