metron-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shane Ardell (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (METRON-1767) Unsubscribe from every observable in the pcap panel UI component
Date Wed, 05 Sep 2018 10:03:00 GMT

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

Shane Ardell commented on METRON-1767:
--------------------------------------

I agree that we should always unsubscribe from Observables when destroying components to prevent
memory leaks. However, what is the advantage to using an observable instead of a promise for
a single event like getPackets?

> Unsubscribe from every observable in the pcap panel UI component
> ----------------------------------------------------------------
>
>                 Key: METRON-1767
>                 URL: https://issues.apache.org/jira/browse/METRON-1767
>             Project: Metron
>          Issue Type: Improvement
>            Reporter: Tamas Fodor
>            Assignee: Tamas Fodor
>            Priority: Major
>
> There are a lot of http requests performed in the pcap panel ui component and we just
unsubscribe from some of them when the component is no longer rendered on the screen. It could
cause memory consumption issues. Because of the active subscriptions, the garbage collector
is not able to remove these objects from the memory, however they're not needed to be there
anymore.
> There's another benefit of unsubscribing from these http calls. If the user leaves the
pcap tab but there are pending requests, the unsubscribe method cancels the active xhrs immediately
so it won't wait for fulfilment unnecessarily. 
> [https://github.com/apache/metron/blob/master/metron-interface/metron-alerts/src/app/pcap/pcap-panel/pcap-panel.component.ts#L54]
> I would also refactor that part when we convert an observable to a promise. I would keep
it as an observable. By doing this, we would be able to unsubscribe from it as well in the
destructor method. Promises are not cancelable. 
> [https://github.com/apache/metron/blob/master/metron-interface/metron-alerts/src/app/pcap/pcap-panel/pcap-panel.component.ts#L70]
>  
> Resources:
> [https://angular.io/guide/lifecycle-hooks#ondestroy]
> {quote}This is the place to free resources that won't be garbage collected automatically.
Unsubscribe from Observables and DOM events. Stop interval timers. Unregister all callbacks
that this directive registered with global or application services. You risk memory leaks
if you neglect to do so.
> {quote}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message