Comments (4)
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.
So are you suggesting all objc calling code would have something in the type that ensures a pool exists?
from metal-rs.
I find it rather obscure that we have no control over when something is released if it decides to use an auto-release pool.
@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, some_operation
knows that an autorelease pool will not be drained in the middle of it, and that should be enough for it. If it wants to take some object and keep it around for longer, it should retain that object. If it wants to return an object, it can autorelease it and it is the caller's responsibility to retain the object.
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.
from metal-rs.
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...
from metal-rs.
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 main
usually does is set up an autorelease pool, and then parts of the runtime will create more from there.
Is there any option like that here? Maybe it could be done in winit?
from metal-rs.
Related Issues (20)
- Investigate use of objc_retainAutoreleasedReturnValue HOT 6
- Make auto-release pools visible HOT 1
- Different behaviour using Metal with Swift in Xcode vs Rust HOT 2
- Incorrect buffer value in compute example HOT 2
- Export MTLAccelerationStructure
- computation performs slower than cpu version in benchmark HOT 3
- Including `metal-rs` on `cargo.toml` results in a compile error due to `cocoa` HOT 1
- trouble with xcode shader debugger locating source code HOT 1
- Question about mesh shaders HOT 3
- Updating version on crates.io HOT 3
- Can't create indirect command buffers
- `new_render_command_encoder` assumes the return value can never be NULL
- MPS Matrix Multiplication HOT 2
- UB in `new_texture` if `newTextureWithDescriptor` fails? HOT 3
- Kernel stops running when I click on another window. HOT 1
- Inconsistent Performance across runs HOT 4
- Discrepency between GPU timing and CPU timing HOT 3
- Example does not support the latest winit HOT 7
- How does one launch a 2D grid of threads using dispatch_threads? HOT 1
- Metal Compiler header file caching HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metal-rs.