Skip to content

Automatic memory management of blocks #573

Open
@madsmtm

Description

@madsmtm

It would be nice if we could get automatic memory management for blocks as well, instead of having to specify returned blocks as *mut Block<dyn Fn()>, and then converting those with RcBlock::copy.

If I'm reading the ARC spec right, it seems like blocks are actually autoreleased according to (mostly) the same rules as other Objective-C objects, and that we need to use objc_retainAutoreleasedReturnValue to access returned block pointers?

A few examples of more complex memory-management:

Also, should blocks be allowed in Id?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-block2Affects the `block2` crateA-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions