You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
Providing a vector to :layout-height or :layout-width such as [10 :dp] leaks the Activity because eventually to-dimension is called with an Activity Context as a parameter ((.getContext wdg)), which then calls get-display-metrics if it gets a vector. get-display-metrics is memoized, so it keeps a reference to its parameter, the Activity, which then prevents the Activity from getting garbage collected after it finishes.
To reproduce:
Create two activities with relative-layouts or linear-layouts in them
Use vector dimensions in the layout-width and/or layout-height
Go back and forth between the activities
Use a memory profiler to view the memory usage, filter by the activity names
Result: You should see multiple instances of each activity kept in memory
Expected result: You should only see at most one instance of each activity
To fix, either:
Use (.getApplicationContext (.getContext wdg)) instead in various parts in traits.clj.
Stop memoizing get-display-metrics.
Note: For any users out there reading this, it remains safe to provide a vector to :text-size since it doesn't call to-dimension.
I'm using 3.2.0, but looking at the latest source the issue should still happen.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Providing a vector to
:layout-height
or:layout-width
such as[10 :dp]
leaks the Activity because eventuallyto-dimension
is called with an Activity Context as a parameter ((.getContext wdg)
), which then callsget-display-metrics
if it gets a vector.get-display-metrics
is memoized, so it keeps a reference to its parameter, the Activity, which then prevents the Activity from getting garbage collected after it finishes.To reproduce:
Result: You should see multiple instances of each activity kept in memory
Expected result: You should only see at most one instance of each activity
To fix, either:
(.getApplicationContext (.getContext wdg))
instead in various parts in traits.clj.get-display-metrics
.Note: For any users out there reading this, it remains safe to provide a vector to
:text-size
since it doesn't callto-dimension
.I'm using 3.2.0, but looking at the latest source the issue should still happen.
The text was updated successfully, but these errors were encountered: