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

ASF GitHub Bot commented on KYLIN-4131:
---------------------------------------

nichunen commented on pull request #799: KYLIN-4131 Fix Broadcaster memory leak
URL: https://github.com/apache/kylin/pull/799
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> 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
>
>         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
(v7.6.14#76016)

Reply via email to