You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Mike Bonnet (Jira)" <ji...@apache.org> on 2019/12/11 18:43:00 UTC

[jira] [Comment Edited] (PROTON-1709) [python] ApplicationEvent causing memory growth

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

Mike Bonnet edited comment on PROTON-1709 at 12/11/19 6:42 PM:
---------------------------------------------------------------

It seems like a {{EventType.___new___()}} method could look up an existing {{EventType}} with the given name in the {{TYPES}} map and return that, only creating a new instance if one doesn't already exist. If {{number}} and/or {{method}} were also specified, it would have to check that they match the existing {{EventType}}, or raise an exception.


was (Author: mbonnet):
It seems like a {{EventType.__new__()}} method could look up an existing {{EventType}} with the given name in the {{TYPES}} map and return that, only creating a new instance if one doesn't already exist. If {{number}} and/or {{method}} were also specified, it would have to check that they match the existing {{EventType}}, or raise an exception.

> [python] ApplicationEvent causing memory growth
> -----------------------------------------------
>
>                 Key: PROTON-1709
>                 URL: https://issues.apache.org/jira/browse/PROTON-1709
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: python-binding
>    Affects Versions: proton-c-0.18.1
>            Reporter: Xin Chen
>            Assignee: Andrew Stitcher
>            Priority: Major
>              Labels: leak
>
> ApplicationEvent creates a new EventType object in the constructor. The EventType object adds itself to the TYPES dict always, even for the same typename. There is no way for the application to avoid this by providing an EventType object directly. Repro code below:
> {code:java}
> import threading
> from proton.reactor import Container, ApplicationEvent, EventInjector
> class Program:
>     def __init__(self, injector):
>         self.injector = injector
>     def on_reactor_init(self, event):
>         event.reactor.selectable(self.injector)
>     def on_hello(self, event):
>         print(event.subject)
>     def on_done(self, event):
>         event.subject.stop()
> e = EventInjector()
> r = Container(Program(e))
> t = threading.Thread(target=r.run)
> t.start()
> for i in range(1, 10000000):
>     e.trigger(ApplicationEvent("hello", subject=str(i)))
> e.trigger(ApplicationEvent("done", subject=r))
> t.join()
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org