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

Add automated leak detection for common scenarios #575

Open
JakeWharton opened this issue Dec 1, 2022 · 5 comments · Fixed by #2266
Open

Add automated leak detection for common scenarios #575

JakeWharton opened this issue Dec 1, 2022 · 5 comments · Fixed by #2266

Comments

@JakeWharton
Copy link
Collaborator

JakeWharton commented Dec 1, 2022

There are common scenarios that occur in Redwood and Treehouse which we should use to ensure branches of the graph are correctly GC'd.

Examples:

  • Remove a composable from RedwoodView composition and the associated view should be GC'd
  • Cancel Redwood composition and the entire composition and all views should go
  • Remove a composable from within Treehouse and the associated view should be GC'd
  • New code is loaded using Treehouse and all old views should go
  • Cancel Treehouse and the entire JS VM and TreehouseView subtype should go

We need to be able to do this on every platform we support.

On Android and JVM we can use LeakCanary. On JS and native we can just do what leak canary is doing: create a weak reference and spin for 5 seconds to see if the reference disappears, optionally trying to force a GC as much as possible (if possible).

@JakeWharton JakeWharton changed the title Add LeakCanary to Emoji Android frontends Add LeakCanary to sample Android frontends May 11, 2023
@JakeWharton JakeWharton changed the title Add LeakCanary to sample Android frontends Add automated leak detection for common scenarios May 13, 2024
@JakeWharton
Copy link
Collaborator Author

@JakeWharton
Copy link
Collaborator Author

For JS we could do https://stackoverflow.com/a/3034245/132047. We are currently using Chromium for tests, but desire to switch to Node.js, in which case it's still V8 so basically the same thing works: https://stackoverflow.com/a/30654451/132047

@swankjesse
Copy link
Collaborator

This came up again today. We could use the XCTest memory leak detection magic. The test should create a LazyList and bind it and confirm nothing leaks

https://developer.apple.com/documentation/xcode/preventing-memory-use-regressions

@JakeWharton
Copy link
Collaborator Author

Still want to do:

  • RedwoodView / TreehouseView
  • WidgetSystem

@JakeWharton
Copy link
Collaborator Author

  • child views after code reload

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

Successfully merging a pull request may close this issue.

3 participants