forked from pocmo/Yaaic
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hold MessageListAdapters and MessageListViews in DeckAdapter to avoid…
… leaks There are at least two significant memory leaks in Yaaic, which cause the client to force close after a few hours with an OutOfMemoryException: (1) The IRCService holds Conversation objects, which contain a MessageListAdapter, which have references to the ConversationActivity context. This causes Activity contexts to outlast the Activity, causing a significant memory leak over time. Fix this by holding the MessageListAdapter in the ConversationActivity's DeckAdapter instead of in the Conversation objects. The DeckAdapter's lifecycle matches that of the Activity, so this prevents the leak. (2) Every call to DeckAdapter.getView()/renderConversation() creates a new MessageListView and adds it to the deck. But adding the view to the deck causes the deck to take a reference to the view, leaking the MessageListView until the Activity is finished. (This has the effect of exacerbating the first leak, since the Activity context holds a reference to the deck.) Fix this leak by caching MessageListViews in the DeckAdapter, and returning an existing MessageListView for a Conversation in getView() if one already exists.
- Loading branch information
Showing
5 changed files
with
78 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,4 +344,4 @@ public void onStatusUpdate() | |
} | ||
} | ||
|
||
} | ||
} |
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