You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2019/09/26 13:43:00 UTC

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

    [ https://issues.apache.org/jira/browse/KYLIN-4131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16938618#comment-16938618 ] 

ASF subversion and git services commented on KYLIN-4131:
--------------------------------------------------------

Commit 8bd6bedbc26da9d6acd9bf2232688bfaf8804e92 in kylin's branch refs/heads/2.6.x from chao long
[ https://gitbox.apache.org/repos/asf?p=kylin.git;h=8bd6bed ]

KYLIN-4131 Fix Broadcaster memory leak


> 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.4#803005)