Skip to content

Commit

Permalink
Merge pull request #9784 from ypbnv/TIMOB-25693
Browse files Browse the repository at this point in the history
[TIMOB-25693] Android: Possible memory leak when setting ListSections on a ListView
  • Loading branch information
Lokesh Choudhary committed Feb 26, 2018
2 parents 9aa6579 + d5ea1ce commit aa9d174
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,11 @@ public View layoutHeaderOrFooterView(TiViewProxy viewProxy)

protected void processSections(Object[] sections)
{

for (ListSectionProxy listSectionProxy : this.sections) {
listSectionProxy.releaseViews();
}
this.sections.clear();

for (int i = 0; i < sections.length; i++) {
processSection(sections[i], -1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.appcelerator.kroll;

import java.lang.ref.WeakReference;
import java.util.HashMap;

import org.appcelerator.kroll.common.AsyncResult;
Expand All @@ -27,7 +28,7 @@ public abstract class KrollObject implements Handler.Callback
protected HashMap<String, Boolean> hasListenersForEventType = new HashMap<String, Boolean>();
protected Handler handler;

private KrollProxySupport proxySupport;
private WeakReference<KrollProxySupport> proxySupport;

public KrollObject()
{
Expand All @@ -40,7 +41,7 @@ public KrollObject()
*/
public void setProxySupport(KrollProxySupport proxySupport)
{
this.proxySupport = proxySupport;
this.proxySupport = new WeakReference<KrollProxySupport>(proxySupport);
}

/**
Expand All @@ -66,8 +67,8 @@ public boolean hasListeners(String event)
public void setHasListenersForEventType(String event, boolean hasListeners)
{
hasListenersForEventType.put(event, hasListeners);
if (proxySupport != null) {
proxySupport.onHasListenersChanged(event, hasListeners);
if (proxySupport != null && proxySupport.get() != null) {
proxySupport.get().onHasListenersChanged(event, hasListeners);
}
}

Expand All @@ -78,8 +79,8 @@ public void setHasListenersForEventType(String event, boolean hasListeners)
*/
public void onEventFired(String event, Object data)
{
if (proxySupport != null) {
proxySupport.onEventFired(event, data);
if (proxySupport != null && proxySupport.get() != null) {
proxySupport.get().onEventFired(event, data);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,8 @@ public void release()
remove(child);
}
children.clear();
children = null;
}
children = null;
proxy = null;
layoutParams = null;
}
Expand Down

0 comments on commit aa9d174

Please sign in to comment.