-
Notifications
You must be signed in to change notification settings - Fork 1
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
Leaked Objects detected during end of program #10
Comments
My bad, I was initializing the object in a global static... |
Okay, I would like to keep the JUCE object away from the user and I can't really work around giving it a static lifetime. In that case drop will never be called an I am leaking memory. One solution that would help me: make |
Hey Stephan!
I agree, this is something I've been thinking about recently too. The original idea was that some of the classes in JUCE require that we've initialised the JUCE "runtime", so I wanted to make it impossible to construct one of these classes before starting the runtime. Thats why The trouble with that as you've found is that the
This could work! I think it would need to be an Another idea I was playing around with was making the JUCE runtime reference counted so that you get back an owned Btw I really enjoyed your Rust talk at ADC! I attended a few days online this year as I was going away on holiday for the second half of the conference, otherwise I would've come and said hello in person. |
Hi James! :) I tried to make it work using an AtomicUsize that counts up always when a new AudioDeviceManager is initialized. When the counter is 0 and you construct the DeviceManager, the init function is called and when the counter goes to 0 in Drop, the shutdown function is called. But I wasn't sure if it should be allowed to create multiple instances in different threads, so if it shouldn't be allowed my solution is not the best :D Here is the code: https://github.com/neodsp/cxx-juce If only one thread should create an audio device manager at a time, maybe it could also just be an atomic flag that indicates someone is using an instance and the other thread needs to wait until the flag is false again or something like that. It could just be a |
This looks great! Ah yeah, as far as I know only one thread can be the JUCE message thread. I think we may need to make the reference count independent of the
Nice, like this idea! Much simpler than what I originally had. Tried this out here - #11. |
Thanks for the update, works great! |
On my linux machine Juce reports those objects as leaking:
Is there something we could do in the wrapper to prevent this from happening?
The text was updated successfully, but these errors were encountered: