Skip to content

Memory leaks #2

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

Open
sten-code opened this issue Feb 26, 2025 · 2 comments
Open

Memory leaks #2

sten-code opened this issue Feb 26, 2025 · 2 comments

Comments

@sten-code
Copy link

You probably already know this, but in the case that you don't. This program is full of memory leaks. I've looked through this code. Everytime you do a heap allocation you don't delete it anywhere. If you do a simple while loop:

while True:
    print("Hello, World!")

This will eventually crash, because inside the visit nodes you return new PyNone() and never clean them up. Inside the while loop visit you evaluate the condition, but never delete the condition object.

@tonisidneimc
Copy link
Member

I’ve just seen the data leak issue you reported two months ago, and I want to prioritize fixing it in the next release. While I’ve been preparing some new features, I recognize that this memory leak is more critical and will focus on resolving it first. I’ve been working alone on the project recently, so I apologize for the delay. Do you have any suggestions on how to approach this problem directly?

@sten-code
Copy link
Author

sten-code commented Apr 11, 2025

Fixing this would be really hard and time consuming, because these allocations happen everywhere throughout the project.

I would recommend using shared_ptr and/or unique_ptr. It's basically a wrapper around a raw pointer, but it will clean itself up when no references exist to itself anymore. Use unique_ptr wherever you can because it's faster than shared_ptr.

If you don't want to use smart pointers, you could probably delete the memory from the destructors.

Feel free to ask anything if you need any help.

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