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

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

Issue 1650873002: Fix memory leak in incremental resolver (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
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 afe021626062dab159e58d4ebd91a185f7e631e1..636d2ad5f89d3e984b02f6085f2bd38dd1fbe77c 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -14,6 +14,8 @@ import 'package:analyzer/src/generated/utilities_collection.dart';
import 'package:analyzer/src/task/model.dart';
import 'package:analyzer/task/model.dart';
+import 'package:analyzer/src/dart/element/element.dart' show ElementImpl;
+
/**
* Return `true` if the given [target] is a priority one.
*/
@@ -384,7 +386,7 @@ class CacheEntry {
* Return the value of the result represented by the given [descriptor], or
* the default value for the result if this entry does not have a valid value.
*/
- dynamic /*=V*/ getValue /*<V>*/ (ResultDescriptor /*<V>*/ descriptor) {
+ dynamic/*=V*/ getValue/*<V>*/(ResultDescriptor/*<V>*/ descriptor) {
ResultData data = _resultMap[descriptor];
if (data == null) {
return descriptor.defaultValue;
@@ -482,8 +484,8 @@ class CacheEntry {
* Set the value of the result represented by the given [descriptor] to the
* given [value].
*/
- void setValue /*<V>*/ (ResultDescriptor /*<V>*/ descriptor,
- dynamic /*=V*/ value, List<TargetedResult> dependedOn) {
+ void setValue/*<V>*/(ResultDescriptor/*<V>*/ descriptor, dynamic/*=V*/ value,
+ List<TargetedResult> dependedOn) {
// {
// String valueStr = '$value';
// if (valueStr.length > 20) {
@@ -582,6 +584,10 @@ class CacheEntry {
// If empty and not explicitly added, remove the entry altogether.
if (_resultMap.isEmpty && !explicitlyAdded) {
_partition.entryMap.remove(target);
+ if (target is ElementImpl) {
+ // Allow mutations now that it's no longer a map key.
+ (target as ElementImpl).frozen = false;
+ }
_partition._removeIfSource(target);
}
// Notify controller.
@@ -922,6 +928,10 @@ abstract class CachePartition {
}
entry._partition = this;
entry.fixExceptionState();
+ if (target is ElementImpl) {
+ // Detect attempts to mutate the map key.
+ target.frozen = true;
+ }
entryMap[target] = entry;
_addIfSource(target);
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/context.dart » ('j') | pkg/analyzer/lib/src/dart/element/element.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698