So I am trying to find out why my app is crashing for
Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 128887990 byte allocation with 16777216 free bytes and 76MB until OOM
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:146)
at java.lang.StringBuilder.append(StringBuilder.java:216)
I have read several post but they all point towards a bitmap image, I am not using any bitmaps, so then I thought maybe I have memory leaks which might cause this, so I installed leakcanary and it is only showing the following leak:
com.google.android.gms.internal.zzcfi.zzfus
references com.google.android.gms.common.api.internal.zzci.zzful
references com.google.android.gms.common.api.internal.zzck.zzfuk
com.tech.activity.dashboard instance
I have searched on Google, Stackoverflow, Github and leak canary and I can not find reference to what this is exactly leaking or how to fix it. I believe this is coming from my google play services location
, but could this cause my OOM error I am seeing? Can someone point me in the right direction?
** EDIT **
As a comment pointed out this is supposed to be a string builder issue, I have never changed how my string builder works since I first released the app, here is my Stringbuilder
which the source comes from AccessibilityNodeInfo
, am I doing something wrong here?
public void processEvent(final AccessibilityNodeInfo source)
{
final StringBuilder sb = new StringBuilder();
processSubEvent(source, 0, sb);
processUIText(source, sb.toString().toLowerCase());
}
private void processSubEvent(final AccessibilityNodeInfo source, final int n, final StringBuilder sb) {
for (int i = 0; i < n; ++i){
sb.append("");
}
if (source != null){
sb.append(tools.getText(source));
sb.append("
");
final int childCount = source.getChildCount();
for (int i = 0; i < childCount; i++)
{
//Log.e(TAG, "Last UI: " + lastUIText);
AccessibilityNodeInfo child = source.getChild(i);
processSubEvent(child, n + 1, sb);
child.recycle();
}
}
}
This is example how the information is being used:
private void processUIText(AccessibilityNodeInfo source, final String text)
{
if (text.contains("hello") && !text.contains("hello again"){
tools.showToast("Hello Reached");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…