How to prevent my ToolWindow from been Garbage collected?
I'm new to IntelliJ platform.
I am writing a plugin with a ToolWindow.
When I run my plugin the ToolWindow shows correctly, but it will got GCed and disappear, then the `finalize()` method was called.
```kotlion
class MyToolWindowFactory: ToolWindowFactory, DumbAware {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
val w = MyPanel(toolWindow)
val contentFactory = ContentFactory.SERVICE.getInstance()
val content = contentFactory.createContent(w, "", false)
toolWindow.contentManager.addContent(content)
}
}
class MyPanel(tw: ToolWindow) : SimpleToolWindowPanel(true, false) {
private val panel= OnePixelSplitter(false,"My.DetailComponentSplitter", 0.3f)
private val list = ProblemListView()
private val detail = ProblemDetailView()
init {
panel.firstComponent = list.getComponent()
panel.secondComponent = detail.getComponent()
setContent(panel)
}
fun finalize() {
print("")
}
}
```
Please sign in to leave a comment.
Xpol Wan,
Can you try with removing the DumbAware from your MyToolWindowFactory and check if the problem still occures?
Thanks for replay!
Remove the DumbAware still got GCed.
Can I ask you to provide more details regarding your IDE/OS versions?
IntelliJ IDEA 2020.1.2 (Community Edition)
Build #IC-201.7846.76, built on June 1, 2020
Runtime version: 11.0.7+10-b765.53 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.5
GC: G1 Young Generation, G1 Old Generation
Memory: 512M
Cores: 8
A similar issue has been reported in our YouTrack. You can follow it here.