Use MAT(Memory Analyzer) to analyze this issue.
- start Kylin, dump a jvm heap info snapshot and import into MAT. We can see there is only one Broadcaster and ProjectManager object.
- Call 'list cube' api and 'reload metadata' api many times. We can see there are many BroadCaster and Manager objects in the memory, which should be recycled by GC, but they are not.
Broadcaster hold the ref of Listener object defined in Manager, and the Listener object hold the ref of Manager, because the impl class of Listener is an inner class of Manager.
ProjectManager.java -> ProjectSyncListener
And Broadcaster can't be recycled by GC because it holds a running thread, which cause the Manager object also not being recycled.
The Broadcaster objects and Manager objects are recycled by GC.