Dynamic Plugins
Installing, updating, and uninstalling plugins without restarting the IDE is available for all plugins following the restrictions listed below.
During plugin development, Auto-Reload also allows code changes to take effect immediately in the sandbox IDE instance. To test whether dynamic installation works correctly, verify installing local build distribution succeeds (see Troubleshooting).
Note that any unloading problems in a production environment will ask the user to restart the IDE.
Restrictions
For a plugin to support this, all restrictions listed below must be met. To verify a plugin locally, invoke Plugin DevKit | Plugin descriptor | Plugin.xml dynamic plugin verification inspection on all plugin descriptor files.
and runFor plugins hosted on the JetBrains Marketplace, the built-in Plugin Verifier will run these checks automatically. See Plugin Verifier for more information on how to run it locally or on CI.
No Use of Components
No Components must be used; existing ones must be migrated to services, extensions, or listeners.
Action Group Requires ID
All <group>
elements must declare a unique id
.
Use Only Dynamic Extensions
Whether defined in the platform itself (IntelliJ Platform Extension Point and Listener List) or coming from other plugins, all used extension points must be marked explicitly as dynamic (see next paragraph).
Some deprecated extension points (for example, com.intellij.configurationProducer
) are intentionally non-dynamic, and their usage should be migrated to the corresponding replacement.
Mark Extension Points as Dynamic
If a plugin defines its own custom extension points, they must adhere to specific usage rules and then be declared ready for dynamic use explicitly.
Configurables Depending on Extension Points
Any Configurable
which depends on dynamic extension points must implement Configurable.WithEpDependencies
.
No Use of Service Overrides
Application, project, and module services declared with overrides="true"
aren't allowed.
Code
CachedValue
Loading/Unloading a plugin clears all cached values created using CachedValuesManager
.
Do Not Store PSI
Do not store references to PSI elements in objects which can survive plugin loading or unloading; use SmartPsiElementPointer
instead.
Do not Use FileType
/Language
as Map Key
Replace with String
from Language.getID()
/FileType.getName()
(use inspection Plugin DevKit | Code | Map key may leak).
Plugin Load/Unload Events
Register DynamicPluginListener
application listener to receive updates on plugin load/unload events.
This can be used to, for example:
cancel long-running activities or disallow unloading due to ongoing processes
clearing data from
UserDataHolder
objects (seeclearInjectorCache()
anddropFileCaches()
inInjectedLanguageManagerImpl
)and similar cases
Resource Cleanup
Use Services implementing Disposable
and perform cleanup in Disposable.dispose()
.
Troubleshooting
When a plugin is being uninstalled or updated, the IDE waits synchronously for the plugin unload and asks for restart if the unloading failed.
If it fails:
Try a newer version of the IDE (eventually latest available from Early Access Program), in some cases platform bugs might be an issue. See this list of known platform issues related to handling dynamic plugins.
Try in a fresh and new configuration (for example, clean the sandbox or use a different configuration directory).
Logging
All events are tracked under the com.intellij.ide.plugins.DynamicPlugins
category in the IDE log file. If a plugin fails to reload, the log will contain a cause as to why.
Diagnosing Leaks
Finding leaks preventing unload
Verify that the IDE is running with the VM parameter
-XX:+UnlockDiagnosticVMOptions
. When using Gradle, specifyrunIde.jvmArgs += "-XX:+UnlockDiagnosticVMOptions"
otherwise Configure JVM Options.Set Registry key
ide.plugins.snapshot.on.unload.fail
totrue
(Go to and typeRegistry
).Trigger the plugin reload.
Open the .hprof memory snapshot generated in the user home directory on plugin unloading, look for the plugin ID string. IntelliJ Ultimate can open memory snapshots directly.
Find the
PluginClassLoader
referencing the plugin ID stringLook at references to the
PluginClassLoader
instance.Every one of them is a memory leak (or part of a memory leak) that needs to be resolved.
When steps 1 and 2 are completed, the log will contain more information about the memory leak. For example, the following shows a chain of field references that is keeping the class loader in memory: