Skip to content

Commit eabb3db

Browse files
Solved memory leak by excessive caching of handler calculation result
1 parent a2053ed commit eabb3db

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
## [0.6.0]
66

7+
### Fixed
8+
- Solved memory leak by excessive caching of handler calculation result
9+
710
### Added
811

912
- Users can now report their exceptions and will be stored in our Sentry installation

src/main/kotlin/org/axonframework/intellij/ide/plugin/markers/handlers/AbstractHandlerLineMarkerProvider.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import com.intellij.codeInsight.daemon.LineMarkerProvider
2121
import com.intellij.psi.PsiElement
2222
import org.axonframework.intellij.ide.plugin.api.MessageHandlerType
2323
import org.axonframework.intellij.ide.plugin.util.annotationResolver
24-
import org.axonframework.intellij.ide.plugin.util.cacheData
2524
import org.axonframework.intellij.ide.plugin.util.resolvePayloadType
2625
import org.axonframework.intellij.ide.plugin.util.toQualifiedName
2726
import org.jetbrains.uast.UAnnotation
@@ -38,9 +37,7 @@ import org.jetbrains.uast.toUElementOfType
3837
*/
3938
abstract class AbstractHandlerLineMarkerProvider : LineMarkerProvider {
4039
override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo<*>? {
41-
val info = element.cacheData("Axon_annotationInfo") {
42-
getInfoForAnnotatedFunction(element)
43-
}
40+
val info = getInfoForAnnotatedFunction(element)
4441
if (info != null) {
4542
return createLineMarker(element, info.first, info.second)
4643
}

src/main/kotlin/org/axonframework/intellij/ide/plugin/util/CacheUtils.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,10 @@
1717
package org.axonframework.intellij.ide.plugin.util
1818

1919
import com.intellij.openapi.project.Project
20-
import com.intellij.openapi.util.Key
21-
import com.intellij.psi.PsiElement
22-
import com.intellij.psi.util.CachedValue
2320
import com.intellij.psi.util.CachedValueProvider
2421
import com.intellij.psi.util.CachedValuesManager
2522
import com.intellij.psi.util.PsiModificationTracker
2623

27-
28-
/**
29-
* Used to cache data on a PsiElement using the user data map.
30-
*
31-
* Uses PsiModificationTracker under the hood, so everything is re-computed when code changes.
32-
*/
33-
fun <T> PsiElement.cacheData(key: String, supplier: () -> T): T {
34-
val cacheKey = Key<CachedValue<T>>(key)
35-
val cache = getUserData(cacheKey)
36-
if (cache == null) {
37-
val createCachedValue = project.createCachedValue(supplier)
38-
putUserData(cacheKey, createCachedValue)
39-
return createCachedValue.value
40-
}
41-
return cache.value
42-
}
43-
4424
/**
4525
* Convenience method to quickly create a cached value for a project based on PSI modifications.
4626
*/

0 commit comments

Comments
 (0)