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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.context.cache; 5 library analyzer.src.context.cache;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/engine.dart' 9 import 'package:analyzer/src/generated/engine.dart'
10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority; 10 show AnalysisEngine, CacheState, InternalAnalysisContext, RetentionPriority;
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 */ 650 */
651 List<TargetedResult> madeIdle() { 651 List<TargetedResult> madeIdle() {
652 maxSize = maxIdleSize; 652 maxSize = maxIdleSize;
653 return flushToSize(); 653 return flushToSize();
654 } 654 }
655 655
656 /** 656 /**
657 * Records that the given [result] was just read from the cache. 657 * Records that the given [result] was just read from the cache.
658 */ 658 */
659 void resultAccessed(TargetedResult result) { 659 void resultAccessed(TargetedResult result) {
660 if (maxSize <= 0) {
661 return;
662 }
660 if (recentlyUsed.remove(result)) { 663 if (recentlyUsed.remove(result)) {
661 recentlyUsed.add(result); 664 recentlyUsed.add(result);
662 } 665 }
663 } 666 }
664 667
665 /** 668 /**
666 * Records that the given [newResult] and [newValue] were stored to the cache. 669 * Records that the given [newResult] and [newValue] were stored to the cache.
667 * Returns [TargetedResult]s that should be flushed from the cache. 670 * Returns [TargetedResult]s that should be flushed from the cache.
668 */ 671 */
669 List<TargetedResult> resultStored(TargetedResult newResult, T newValue) { 672 List<TargetedResult> resultStored(TargetedResult newResult, T newValue) {
673 if (maxSize <= 0) {
674 return TargetedResult.EMPTY_LIST;
675 }
670 if (!recentlyUsed.remove(newResult)) { 676 if (!recentlyUsed.remove(newResult)) {
671 int size = policy.measure(newValue); 677 int size = policy.measure(newValue);
672 resultSizeMap[newResult] = size; 678 resultSizeMap[newResult] = size;
673 currentSize += size; 679 currentSize += size;
674 } 680 }
675 recentlyUsed.add(newResult); 681 recentlyUsed.add(newResult);
676 return flushToSize(); 682 return flushToSize();
677 } 683 }
678 684
679 /** 685 /**
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 class UniversalCachePartition extends CachePartition { 978 class UniversalCachePartition extends CachePartition {
973 /** 979 /**
974 * Initialize a newly created cache partition, belonging to the given 980 * Initialize a newly created cache partition, belonging to the given
975 * [context]. 981 * [context].
976 */ 982 */
977 UniversalCachePartition(InternalAnalysisContext context) : super(context); 983 UniversalCachePartition(InternalAnalysisContext context) : super(context);
978 984
979 @override 985 @override
980 bool isResponsibleFor(AnalysisTarget target) => true; 986 bool isResponsibleFor(AnalysisTarget target) => true;
981 } 987 }
OLDNEW
« 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