Skip to content
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

Objective-C: Memory management; tracking object lifetime #100

Open
wokalski opened this issue Mar 29, 2019 · 1 comment
Open

Objective-C: Memory management; tracking object lifetime #100

wokalski opened this issue Mar 29, 2019 · 1 comment

Comments

@wokalski
Copy link
Member

We have a sort of simple situation with our objective C bindings. Even though objc uses reference counting we only need to modify reference count twice; increase when we create an object (somewhere in nativeComponent's make) and decrement it when we dispose it possibly in deleteNode. I tend to think we should explicitly release objects when we no longer want them and expect all objects to be retained on the objc side before handing them to OCaml.

BriskToolbar is a good example of a trickier case.
https://github.com/briskml/brisk/blob/master/renderer-macos/lib/stubs/BriskToolbar.c#L116

cc @manuhornung who has similar problems in Revery.

@manu-unter
Copy link

The approaches I learned about here should apply in a very similar way to ref-counted Objective-C as they do for C++ smart pointers, so I'm leaving this here for reference

https://discuss.ocaml.org/t/wrapping-c-std-shared-ptr-and-similar-smart-pointers/3582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants