Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1719)

Unified Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 1154563002: Fix for a memory leak in CacheFlushManager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/cache.dart
diff --git a/pkg/analyzer/lib/src/context/cache.dart b/pkg/analyzer/lib/src/context/cache.dart
index a3d22bef7c9d63c87cbce44c747dcd18c391d6f7..fc188ba1ec20ce9f7213c8b3c7536cac67adc211 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -657,6 +657,9 @@ class CacheFlushManager<T> {
* Records that the given [result] was just read from the cache.
*/
void resultAccessed(TargetedResult result) {
+ if (maxSize <= 0) {
+ return;
+ }
if (recentlyUsed.remove(result)) {
recentlyUsed.add(result);
}
@@ -667,6 +670,9 @@ class CacheFlushManager<T> {
* Returns [TargetedResult]s that should be flushed from the cache.
*/
List<TargetedResult> resultStored(TargetedResult newResult, T newValue) {
+ if (maxSize <= 0) {
+ return TargetedResult.EMPTY_LIST;
+ }
if (!recentlyUsed.remove(newResult)) {
int size = policy.measure(newValue);
resultSizeMap[newResult] = size;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698