-
Notifications
You must be signed in to change notification settings - Fork 47
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
Potential memory leak #73
Comments
Did you guys ever find a resolution or workaround for this issue? We're experiencing something similar with v0.9.7 |
Specifically it's this code
In _compiler.py that seems to keep its reference. |
@radove @fantamiracle This is the fix for key in list(sys.modules.keys()): The dynamically generated module when compiling the template is not de-referenced. We were compiling a new template every request on a Django (the nature of the template is dynamic because it can be user generated in our use-case so we can't define them as globals), and this was causing the templates to continue to exist even if the variable that the dict is assigned to gets dereferenced |
As an addendum, as they state it, the compiler is not threadsafe, so you will need to use a lock when initializing the Compiler and compiling lock = threading.Lock() def compile_prompt_template(prompt: str, args: dict): Something like the above. |
If you wait for a few minutes you can see the memory bloat.
pybar3 version: 0.9.7
Any thoughts for a fix to a way to get around it?
The text was updated successfully, but these errors were encountered: