You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by "Xiaoxiang Yu (Jira)" <ji...@apache.org> on 2019/09/02 02:39:00 UTC

[jira] [Resolved] (KYLIN-4131) Broadcaster memory leak

     [ https://issues.apache.org/jira/browse/KYLIN-4131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoxiang Yu resolved KYLIN-4131.
---------------------------------
    Fix Version/s: v2.6.4
       Resolution: Fixed

> Broadcaster memory leak
> -----------------------
>
>                 Key: KYLIN-4131
>                 URL: https://issues.apache.org/jira/browse/KYLIN-4131
>             Project: Kylin
>          Issue Type: Bug
>          Components: Metadata
>            Reporter: Chao Long
>            Assignee: Chao Long
>            Priority: Critical
>             Fix For: v3.0.0, v2.6.4
>
>         Attachments: image-2019-08-12-16-39-46-262.png, image-2019-08-12-16-39-52-327.png, image-2019-08-12-17-16-05-532.png, image-2019-08-12-17-22-15-783.png, image-2019-08-12-17-22-23-477.png
>
>
> h3. *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.
>  !image-2019-08-12-17-22-15-783.png|width=721,height=520!
>  # 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.
>  !image-2019-08-12-17-22-23-477.png|width=724,height=498!
>  
> *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
> {code:java}
> private Map<String, List<Listener>> listenerMap = Maps.newConcurrentMap();
> {code}
>  ProjectManager.java -> ProjectSyncListener
> {code:java}
> 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);
> }
> }
> {code}
> 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.
> !image-2019-08-12-17-16-05-532.png!
>  



--
This message was sent by Atlassian Jira
(v8.3.2#803003)