-
Notifications
You must be signed in to change notification settings - Fork 111
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
Integrate auto-release pool into the type system #86
Comments
In principle, just about any obj-c code should be assumed to require autoreleasepool. Empirical proof that a method doesn't need it is not fully sound, as a system update might always change the underlying libs to change the fact. |
@kvark I believe that ObjC code that relies on an autorelease pool running or not running until specific times would generally be considered unsound. If something is autoreleased and returned to you, you must retain it if you care about it staying alive. In your example, Are there any specific situations where you're worried about objects being autoreleased too early? I'd recommend retaining them and using some smart pointer types that don't release until dropped. |
I find auto-release pools managed by the system to be unreliable. IIRC, we clearly see a memory leak if we don't wrap execution of relevant bits with ar-pool. Maybe it's a winit issue? We've been trying to cover all the essential code bits in our own pools, so that we can guarantee the memory is freed, that's why I thought about this idea... |
Aha! My bad. So you're just interested in guaranteeing that this code is run inside some autorelease pool, not necessarily that the pool lasts for a certain duration? That's not a problem I've thought about very much. In iOS or mac apps, the first thing Is there any option like that here? Maybe it could be done in winit? |
I find it rather obscure that we have no control over when something is released if it decides to use an auto-release pool. I wonder if we could encode this into the type system, so that a user-provided auto-release context is required in any operation that ends up using it implicitly. Something along these lines:
is this feasible or totally unrealistic? @grovesNL @scoopr @SSheldon
The text was updated successfully, but these errors were encountered: