The report points to a memory leak in Markdown Navigator plugin where ProjectImpl objects are leaked (which are large structures to closed projects). These objects are kept alive due to a reference in MdProjectSettings.myProject. MdProjectSettings is a Disposable object itself and has been already disposed.
To drill further, such disposed MdProjectSettings is kept alive due to LafManager.addLafManagerListener() call. GitHub doesn't show the code for the latest version, so the following is my best guess of what might be the cause.
Likely, the code that registers MdProjectSettings as a listener should use LafManager.addLafManagerListener(mdProjectSettings, mdProjectSettings) instead of LafManager.addLafManagerListener(mdProjectSettings). This will remove the listener once MdProjectSettings is disposed.
Another option is to explicitly call removeLafManagerListener in MdProjectSettings.dispose().
Repro is quite simple: open and then close project when MultiMarkdown plugin is enabled. You might need to edit a .md file, but I think it is not necessary to cause a leak. Observe the memory heap with a profiler (VisualVM, YourKit), you'll notice more and more ProjectImpl objects are being kept alive.
Android Studio runs memory analysis when memory is low. Below is a fragment of such report sent by a user:
The report points to a memory leak in Markdown Navigator plugin where
ProjectImpl
objects are leaked (which are large structures to closed projects). These objects are kept alive due to a reference inMdProjectSettings.myProject
.MdProjectSettings
is aDisposable
object itself and has been already disposed.To drill further, such disposed
MdProjectSettings
is kept alive due toLafManager.addLafManagerListener()
call. GitHub doesn't show the code for the latest version, so the following is my best guess of what might be the cause.Likely, the code that registers
MdProjectSettings
as a listener should useLafManager.addLafManagerListener(mdProjectSettings, mdProjectSettings)
instead ofLafManager.addLafManagerListener(mdProjectSettings)
. This will remove the listener once MdProjectSettings is disposed.Another option is to explicitly call
removeLafManagerListener
inMdProjectSettings.dispose()
.Repro is quite simple: open and then close project when MultiMarkdown plugin is enabled. You might need to edit a .md file, but I think it is not necessary to cause a leak. Observe the memory heap with a profiler (VisualVM, YourKit), you'll notice more and more ProjectImpl objects are being kept alive.
Verified with Markdown Navigator 2.9.7.