Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a memory leak,I need help #208

Closed
kansnow opened this issue Mar 27, 2024 · 3 comments
Closed

There is a memory leak,I need help #208

kansnow opened this issue Mar 27, 2024 · 3 comments

Comments

@kansnow
Copy link

kansnow commented Mar 27, 2024

import time
import pulsar
import sys
import gc

client = pulsar.Client('pulsar://localhost:6650')

def connect_to_pulsar():
    producer = None
    try:
        producer = client.create_producer('my-topic')
        producer.send(b'Hello Pulsar!')
    except Exception as e:
        print(f"Connection to Pulsar failed: {e}")
    finally:
        size = sys.getsizeof(client)
        print(f"Memory usage of {client.__class__.__name__} object: {size} bytes")
        if producer:
            producer.close()
        gc.collect()

for _ in range(1000000):
    connect_to_pulsar()
    time.sleep(1)

client.close()

there is my code,I am using pulsar-client with version 2.9.1. when I run this code in python3, Process memory keeps growing.
Where exactly is the problem?

@merlimat
Copy link
Contributor

Can you try with latest version 3.4.0? https://pypi.org/project/pulsar-client/

@kansnow
Copy link
Author

kansnow commented Mar 28, 2024

Can you try with latest version 3.4.0? https://pypi.org/project/pulsar-client/

ok, I'll try upgrading the version

@kansnow
Copy link
Author

kansnow commented Mar 28, 2024

Can you try with latest version 3.4.0? https://pypi.org/project/pulsar-client/

Thank you very much. I used the top command to check the memory usage of the process. After upgrading the version, the memory did not grow anymore

@kansnow kansnow closed this as completed Mar 28, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants