Memory Leaks & Outofmemoryerror
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
Solution 1:
This is example how the information is being used:
Then don't build a string. Build a boolean
. Something akin to this should work:
classWhatever {
privateboolean helloSeen=false;
privateboolean helloAgainSeen=false;
publicvoidprocessEvent(final AccessibilityNodeInfo source)
{
processSubEvent(source);
}
privatevoidprocessSubEvent(final AccessibilityNodeInfo source) {
if (source != null){
String text=tools.getText(source);
if (text.contains("hello")) {
helloSeen=true;
}
if (text.contains("hello again")) {
helloAgainSeen=true;
}
if (!helloSeen || !helloAgainSeen) {
finalintchildCount= source.getChildCount();
for (inti=0; i < childCount; i++)
{
//Log.e(TAG, "Last UI: " + lastUIText);AccessibilityNodeInfochild= source.getChild(i);
processSubEvent(child);
child.recycle();
}
}
}
}
}
After processEvent()
returns, helloSeen
and helloAgainSeen
will reflect whether your messages were encountered anywhere.
Post a Comment for "Memory Leaks & Outofmemoryerror"