KT-30688: Fix memory leak on module in disposer after onTooComplexChange
Remove explicit cache entry removal, use weak map instead #KT-30688 fixed
This commit is contained in:
+2
-5
@@ -17,7 +17,6 @@ import com.intellij.openapi.project.Project
|
|||||||
import com.intellij.openapi.project.rootManager
|
import com.intellij.openapi.project.rootManager
|
||||||
import com.intellij.openapi.roots.ModuleRootEvent
|
import com.intellij.openapi.roots.ModuleRootEvent
|
||||||
import com.intellij.openapi.roots.ModuleRootListener
|
import com.intellij.openapi.roots.ModuleRootListener
|
||||||
import com.intellij.openapi.util.Disposer
|
|
||||||
import com.intellij.openapi.util.Key
|
import com.intellij.openapi.util.Key
|
||||||
import com.intellij.openapi.vfs.VfsUtilCore
|
import com.intellij.openapi.vfs.VfsUtilCore
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
@@ -219,10 +218,9 @@ class ImplicitPackagePrefixCache(private val project: Project) {
|
|||||||
class PerModulePackageCacheService(private val project: Project) {
|
class PerModulePackageCacheService(private val project: Project) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disposal of entries handled by Module child Disposable registered in packageExists
|
* Actually an WeakMap<Module, SoftMap<ModuleSourceInfo, SoftMap<FqName, Boolean>>>
|
||||||
* Actually an StrongMap<Module, SoftMap<ModuleSourceInfo, SoftMap<FqName, Boolean>>>
|
|
||||||
*/
|
*/
|
||||||
private val cache = ConcurrentHashMap<Module, ConcurrentMap<ModuleSourceInfo, ConcurrentMap<FqName, Boolean>>>()
|
private val cache = ContainerUtil.createConcurrentWeakMap<Module, ConcurrentMap<ModuleSourceInfo, ConcurrentMap<FqName, Boolean>>>()
|
||||||
private val implicitPackagePrefixCache = ImplicitPackagePrefixCache(project)
|
private val implicitPackagePrefixCache = ImplicitPackagePrefixCache(project)
|
||||||
|
|
||||||
private val pendingVFileChanges: MutableSet<VFileEvent> = mutableSetOf()
|
private val pendingVFileChanges: MutableSet<VFileEvent> = mutableSetOf()
|
||||||
@@ -323,7 +321,6 @@ class PerModulePackageCacheService(private val project: Project) {
|
|||||||
checkPendingChanges()
|
checkPendingChanges()
|
||||||
|
|
||||||
val perSourceInfoCache = cache.getOrPut(module) {
|
val perSourceInfoCache = cache.getOrPut(module) {
|
||||||
Disposer.register(module, Disposable { cache.remove(module) })
|
|
||||||
ContainerUtil.createConcurrentSoftMap()
|
ContainerUtil.createConcurrentSoftMap()
|
||||||
}
|
}
|
||||||
val cacheForCurrentModuleInfo = perSourceInfoCache.getOrPut(moduleInfo) {
|
val cacheForCurrentModuleInfo = perSourceInfoCache.getOrPut(moduleInfo) {
|
||||||
|
|||||||
Reference in New Issue
Block a user