-
Notifications
You must be signed in to change notification settings - Fork 181
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
Add keepalive cache to keep objects stored as void* from being gc'ed. #250
Add keepalive cache to keep objects stored as void* from being gc'ed. #250
Conversation
Indeed, pyimgui does not intent to be thread-safe. DearImgui itself is not thread-safe. It is the responsibility of the user to take care of that if it needs it. So I don't think this is an issue here. Thank you very much for your help! I added test cases to reproduce issue #248. I also changed |
Hmm, I have (and had) "Allow edits by maintainers" checked, so you should have access. |
afaik editing a contributors branch only work with https, not over ssh. |
Yes indeed, my bad. Apparently, this was a bug with the push command. Here is my proposal for inserting What do you think about it? |
Thanks for your help! |
Fixes: #248
Here is an alternative fix for #248. This approach keeps a cache of objects stored as void pointers so that the corresponding Python objects are not garbage collected before they are needed. The cache is cleared every new_frame(). The cache is not threadsafe, but I assume pyimgui does not intend to be threadsafe. The cache could cause memory use to increase without bound if the user does something nonsensical, e.g.
I chose the cache to be a list because it would be the fastest and easiest option.
Another option would be to use a dict of id(object) -> object, which would be slower but not suffer from the memory issue above.