-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix retain cycle in JSClosure by weak reference to the closure holder ```swift let c1 = JSClosure { _ in .undefined } consume c1 ``` did not release the `JSClosure` itself and it leaked the underlying JavaScript closure too because `JSClosure` -> JS closure thunk -> Closure registry entry -> `JSClosure` reference cycle was not broken when using FinalizationRegistry. (Without FR, it was broken by manual `release` call.) Note that weakening the reference does not violates the contract that function reference should be unique because holding a weak reference does deinit but not deallocate the object, so ObjectIdentifier is not reused until the weak reference in the registry is removed. * Fix the test suite for violation of the closure lifetime contract The test suite was not properly releasing the closures but they have not been revealed as a problem because those closures were leaked conservatively. * Report where the closure is created when it violates the lifetime contract This additional information will help developers to find the root cause * Flatten two-level object reference in ClosureEntry
- Loading branch information
1 parent
3b5af3d
commit d9a4a9f
Showing
4 changed files
with
103 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters