[
https://issues.apache.org/jira/browse/PROTON-2111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16995890#comment-16995890
]
Mike Bonnet commented on PROTON-2111:
-------------------------------------
As to why we're sending messages this way, sending messages is a (relatively)
infrequent operation, so we don't want to keep a connection open all the time
just to send the occasional message. We'd rather connect to the broker, send a
message, close the connection, and be on our way. We tried to do this by using
a single {{Container}} and calling {{start()}}, {{process()}}, and {{stop()}}
when we need to send a single message, but we were told reusing a single
{{Container}} in that manner was not supported (and as I recall, resulted in
tracebacks when trying to use a {{Container}} that had previously had
{{stop()}} called in it).
Since {{BlockingConnection}} uses an internal {{Container}} instance, I don't
think that would avoid this memory leak.
> python: memory leak on Container, SSL, and SSLDomain objects
> ------------------------------------------------------------
>
> Key: PROTON-2111
> URL: https://issues.apache.org/jira/browse/PROTON-2111
> Project: Qpid Proton
> Issue Type: Bug
> Components: python-binding
> Affects Versions: proton-c-0.28.0
> Reporter: Chenxiong Qi
> Priority: Major
>
> I have an application using qpid.proton to interact with ActiveMQ broker to
> publish messages. Following is a fake script showing an example of the app
> works to send a message.
> {noformat}
> class SampleSender(proton.handlers.MessagingHandler):
> def __init__(self, msg_id, *args, **kwargs):
> super(SampleSender, self).__init__(*args, **kwargs)
> self.msg_id = msg_id
> def on_start(self, event):
> ssl_domain = proton.SSLDomain(proton.SSLDomain.MODE_CLIENT)
> ssl_domain.set_credentials(producer_config['certificate'],
> producer_config['private_key'],
> None)
> ssl_domain.set_trusted_ca_db(producer_config['trusted_certificates'])
> ssl_domain.set_peer_authentication(proton.SSLDomain.VERIFY_PEER)
> conn = event.container.connect(urls=producer_config['urls'],
> reconnect=False,
> ssl_domain=ssl_domain)
> event.container.create_sender(conn,
> target='topic://VirtualTopic.event')
> def on_sendable(self, event):
> msg = proton.Message(body={'msg-id': self.msg_id, 'name': 'python'})
> event.sender.send(msg)
> event.sender.close()
> event.connection.close()
> def send_msg(msg_id):
> container = proton.reactor.Container(SampleSender(msg_id))
> container.run()
> objgraph.show_growth()
> for i in range(3):
> send_msg(i + 1)
> new_ids = objgraph.get_new_ids()
> print(objgraph.at_addrs(new_ids['SSLDomain']))
> print(objgraph.at_addrs(new_ids['Container']))
> print(objgraph.at_addrs(new_ids['SSL']))
> {noformat}
> Each time to publish a message, a new Container object is created and a new
> handler object is created and passed to that container. After the code runs
> several times, Container, SSL and SSLDomain objects remain in memory and are
> not collected. I use objgraph to find out those objects.
> I'm using Fedora 30 and python-qpid-proton 0.28.0.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]