From 66f4aad23fa96b589489afb2c0586b8611ca05bb Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 8 Jan 2026 12:57:24 +0100 Subject: [PATCH] (part of IJPL-220534) clean internal datastructures holding references to services on dispose, to make memdumps shorter and memleaks more revealing GitOrigin-RevId: 8b506d01038c709b097571b32c5d81f8f557cf9c --- .../com/intellij/serviceContainer/ComponentManagerImpl.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt b/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt index 7d38bf4f1161..81e36304103e 100644 --- a/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt +++ b/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt @@ -1185,6 +1185,7 @@ abstract class ComponentManagerImpl( if (!containerState.compareAndSet(ContainerState.DISPOSED, ContainerState.DISPOSE_COMPLETED)) { throw IllegalStateException("Expected current state is DISPOSED, but actual state is ${containerState.get()} ($this)") } + pluginServicesStore.clearPotentialLeaks() } override fun stopServicePreloading() { @@ -1421,6 +1422,11 @@ private class PluginServicesStore { fun removeDynamicServices(descriptor: IdeaPluginDescriptor): List { return dynamicServices.remove(descriptor)?.toList() ?: java.util.List.of() } + + fun clearPotentialLeaks() { + dynamicServices.clear() + regularServices.clear() + } } private fun createPluginExceptionIfNeeded(error: Throwable, pluginId: PluginId): RuntimeException {