Description
Test evidence
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.
Root cause
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.
Broadcaster.java
private Map<String, List<Listener>> listenerMap = Maps.newConcurrentMap();
ProjectManager.java -> ProjectSyncListener
private class ProjectSyncListener extends Broadcaster.Listener { @Override public void onEntityChange(Broadcaster broadcaster, String entity, Event event, String cacheKey) throws IOException { String project = cacheKey; if (event == Event.DROP) { removeProjectLocal(project); return; } reloadProjectQuietly(project); broadcaster.notifyProjectSchemaUpdate(project); broadcaster.notifyProjectDataUpdate(project); } }
And Broadcaster can't be recycled by GC because it holds a running thread, which cause the Manager object also not being recycled.
After Fix
The Broadcaster objects and Manager objects are recycled by GC.
Attachments
Attachments
Issue Links
- links to