Possible memory leak receiving messages in servicebus 0.50.3
See original GitHub issue- Package Name: servicebus
- Package Version: 0.50.3
- Operating System: Linux Alpine/Debian, OSX
- Python Version: 3.8.6
Describe the bug Apparently memory leaks from receiving messages.
To Reproduce Steps to reproduce the behavior:
- create a queue client
- create a receiver
- receive (and ignore) a message
- back to point 1
Expected behavior No relevant memory usage increase.
Code
Here a sample of the code I use to replicate. Notice I am not processing messages and I am running against an empty queue.
import os
from azure.servicebus import ServiceBusClient, ReceiveSettleMode
if __name__ == '__main__':
service_bus_client = ServiceBusClient(service_namespace=os.environ['AZURE_BUS_NAMESPACE'],
shared_access_key_name=os.environ['AZURE_BUS_KEY_NAME'],
shared_access_key_value=os.environ['AZURE_BUS_KEY_VALUE'])
queue_name = '-'.join([os.environ['AZURE_BUS_QUEUE'], 'low'])
for _ in range (1000000):
# ofc I could create the queue once, but this is closer to my actual code
queue = service_bus_client.get_queue(queue_name=queue_name)
with queue.get_receiver(mode=ReceiveSettleMode.PeekLock) as receiver:
msg_batch = receiver.fetch_next(max_batch_size=1, timeout=1)
# notice I do not really expect to receive any message, printing just to keep it busy....
print(msg_batch)
Additional context
I know that I am not running on the latest version, but I have the feeling the issue might be in the uamqp layer and therefore of interest for also the new versions as well.
Issue Analytics
- State:
- Created 3 years ago
- Comments:22 (9 by maintainers)
Top Results From Across the Web
Memory leak in the Azure Service Bus Queue - MSDN
Every time this code is executed memory leaks approximately 1Mb. I tried to put "BrokeredMessage" inside "using" statement but that did not help ......
Read more >azure-servicebus - PyPI
Send and receive messages within your Service Bus channels. Utilize message locks, sessions, and dead letter functionality to implement complex messaging ...
Read more >Azure Message Bus not releasing memory - Stack Overflow
The memory that is used maybe waiting for garbage collection t run. Garbage collection is not predictable when it will run. It is...
Read more >Releases - ImmyDocs
Added a warning message whenever the Ephemeral Agent's Ping RPC method takes ... job causing memory to bloat; You can now get registration...
Read more >Index of /pub/fedora/linux/releases/35/Everything/x86_64/os ...
perl-Devel-Leak-0.03-47.fc35.x86_64.rpm 2021-07-27 04:33 18K [ ] ... perl-Email-Received-1.00-25.fc35.noarch.rpm 2021-07-27 04:34 18K [ ] ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

apologize for missing the thread here @alberto-delgado-maersk, and thanks @miroag for bringing it to my attention! I’ll investigate into the issue this week.
Hi @yunhaoling, it seems there are still some memory issues in version 7.2.0 of the service bus python package.
I ran a similar version to the script below for around 6 hours, explicitly calling the GC every few iterations and the memory just kept growing.
Below you can see also a plot of how the memory grows:
When instead I initialized the service bus client within the while loop above, we see that the memory increases at a much slower rate:
Could you check if you see the same at your end?