title |
---|
Dynamic Plugins |
Starting with 2020.1 release, the ability to install, update and uninstall plugins without restarting the IDE is available in the IntelliJ Platform. During plugin development, Auto-Reload also allows code changes to take effect immediately in the sandbox IDE instance.
NOTE If a plugin requires restart (e.g., due to using native libraries) specify
require-restart="true"
for<idea-plugin>
root tag inplugin.xml
.
For a plugin to support this, all restrictions listed below must be met. To verify a plugin locally, run Plugin DevKit | Plugin descriptor | Plugin.xml dynamic plugin verification
inspection on all plugin descriptor files (required plugin.xml
as well as any additional files).
For plugins hosted on the JetBrains Plugins Repository the built-in Plugin Verifier will run these checks automatically. See Plugin Verifier for more information on how to run it locally.
No Components must be used; existing ones must be migrated to services, extensions or listeners.
All <group>
s must declare a unique id
.
All extensions, whether defined in the platform itself or coming from other plugins, must be marked as dynamic (see next paragraph).
Some deprecated extension points (e.g., com.intellij.configurationProducer
) are intentionally non-dynamic, and their usage should be migrated to the corresponding replacement.
All extension points provided by the plugin must adhere to specific usage rules and then be declared ready for dynamic use explicitly.
Any Configurable
which depends on dynamic extension points must implement Configurable.WithEpDependencies
.
Application, project and module services declared with overrides="true"
are not allowed.
NOTE Loading and unloading plugins happens in EDT and under write action.
Loading/Unloading a plugin clears all cached values created using CachedValuesManager
.
Do not store references to PSI elements in objects which can survive plugin loading or unloading, use SmartPsiElementPointer
instead.
Register com.intellij.ide.plugins.DynamicPluginListener
application listener to receive updates on plugin load/unload events.
This can be used to e.g. cancel long-running activities or disallow unload due to ongoing processes.
When a plugin is being uninstalled or updated, the IDE waits synchronously for plugin unload and asks for restart if the unload failed.
All events are tracked under com.intellij.ide.plugins.DynamicPlugins
category in IDE log file.
To find leaks preventing clean unload, perform the following steps:
- Set registry key
ide.plugins.snapshot.on.unload.fail
totrue
- Verify that IDE runs with VM parameter
-XX:+UnlockDiagnosticVMOptions
- Open the
.hprof
snapshot generated on plugin unload, look for the plugin ID string - Find the
PluginClassLoader
referencing the plugin ID string - Look 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.