-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
After #5641 lands, it is possible that some or all of the autorelease pools in the code will no longer be necessary.
Autorelease pools are currently used for set_label, because the metal-rs's helper nsstring_from_str returns an autoreleased object (see metal-rs#218 Don't use auto-release pool in string-related methods), and for certain operations that create an object but don't literally have "create" or "new" in the name, notably, for command encoders and passes. (In some cases metal-rs has a new_ prefix even when the underlying function does not.)
However @madsmtm notes in #5641 (comment) that the objc_retainAutoreleasedReturnValue optimization that is able to match the autorelease with a retain in the caller and determine that they can be cancelled relies on some fairly low-level machine code inspection magic, and may not be 100% reliable. This may mean that it is safer to preserve the autorelease pools to avoid the possibility of a very confusing situationally-depenent memory leak. If we do decide to keep them, we should document why in the code.