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

Ref patterns for native global variables #1570

Merged
merged 1 commit into from Sep 10, 2019
Merged

Ref patterns for native global variables #1570

merged 1 commit into from Sep 10, 2019

Conversation

pyricau
Copy link
Member

@pyricau pyricau commented Sep 10, 2019

Leaks are often caused by native global variables holding references to live objects. On Android this is super common due to the IPC mechanism holding on to instances until the stub in the other process is garbage collected.

Fixes #1562

Leaks are often caused by native global variables holding references to live objects. On Android this is super common due to the IPC mechanism holding on to instances until the stub in the other process is garbage collected.

Fixes #1562
@pyricau pyricau added this to the 2.0 Next Release milestone Sep 10, 2019
SemClipboardManager inner classes are held by native references due to IPC calls
""".trimIndent()
references += nativeGlobalVariableLeak(
"com.samsung.android.content.clipboard.SemClipboardManager$1", description
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming it is not a typo that new ref has $1 in the end
UPDATE: nevermind, it is below >_>


data class NativeGlobalVariablePattern(val className: String) : ReferencePattern() {
override fun toString(): String {
return "native global variable referencing $className"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: here and in other classes I think it would be better for readability to go with the expression body:
override fun toString() = "native global variable referencing $className"
The strings are short enough to fi within line limit and it will result in nice 3-row data classes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging, will follow up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pyricau pyricau merged commit 879ab7c into master Sep 10, 2019
@pyricau pyricau deleted the py/native_globals branch September 10, 2019 23:27
pyricau added a commit that referenced this pull request Sep 10, 2019
@pyricau pyricau mentioned this pull request Sep 10, 2019
pyricau added a commit that referenced this pull request Sep 11, 2019
pyricau added a commit that referenced this pull request Sep 11, 2019
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

Successfully merging this pull request may close these issues.

Pattern matching for known native reference leaks
2 participants