void MemoryCache::pruneLiveResources(bool shouldDestroyDecodedDataForAllLiveResources) { unsigned capacity = shouldDestroyDecodedDataForAllLiveResources ? 0 : liveCapacity(); if (capacity && m_liveSize <= capacity) return; unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again. pruneLiveResourcesToSize(targetSize, shouldDestroyDecodedDataForAllLiveResources); }
void MemoryCache::pruneLiveResourcesToPercentage(float prunePercentage) { if (!m_pruneEnabled) return; if (prunePercentage < 0.0f || prunePercentage > 0.95f) return; unsigned currentSize = m_liveSize + m_deadSize; unsigned targetSize = static_cast<unsigned>(currentSize * prunePercentage); pruneLiveResourcesToSize(targetSize); }
void MemoryCache::pruneLiveResources() { if (!m_pruneEnabled) return; unsigned capacity = liveCapacity(); if (capacity && m_liveSize <= capacity) return; unsigned targetSize = static_cast<unsigned>(capacity * cTargetPrunePercentage); // Cut by a percentage to avoid immediately pruning again. pruneLiveResourcesToSize(targetSize); }