Use WeakKeySoftValueMap in ResolveElementCache

Otherwise results are effectively retained in the maps until we're close
to OutOfMemory.
While we mostly need them for a short time (especially in the case we
run resolution during usages search).

The possible problem is that the values may become too short-living,
but now using these maps is a conventional solution for similar tasks in
Java resolve
This commit is contained in:
Denis Zharkov
2018-03-29 15:03:53 +02:00
parent 96ab705de1
commit 26714d56d8
@@ -77,7 +77,7 @@ class ResolveElementCache(
CachedValuesManager.getManager(project).createCachedValue(
CachedValueProvider<MutableMap<KtElement, ResolveElementCache.CachedFullResolve>> {
CachedValueProvider.Result.create(
ContainerUtil.createConcurrentSoftValueMap<KtElement, CachedFullResolve>(),
ContainerUtil.createConcurrentWeakKeySoftValueMap<KtElement, CachedFullResolve>(),
PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT,
resolveSession.exceptionTracker
)
@@ -103,7 +103,7 @@ class ResolveElementCache(
CachedValuesManager.getManager(project).createCachedValue(
CachedValueProvider<MutableMap<KtExpression, ResolveElementCache.CachedPartialResolve>> {
CachedValueProvider.Result.create(
ContainerUtil.createConcurrentSoftValueMap<KtExpression, CachedPartialResolve>(),
ContainerUtil.createConcurrentWeakKeySoftValueMap<KtExpression, CachedPartialResolve>(),
PsiModificationTracker.MODIFICATION_COUNT,
resolveSession.exceptionTracker
)