Memory Leaks & OutOfMemoryError

后端 未结 1 1438
不知归路
不知归路 2020-12-20 02:49

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 16777         


        
相关标签:
1条回答
  • 2020-12-20 03:42

    This is example how the information is being used:

    Then don't build a string. Build a boolean. Something akin to this should work:

    class Whatever {
        private boolean helloSeen=false;
        private boolean helloAgainSeen=false;
    
        public void processEvent(final AccessibilityNodeInfo source)
        {
            processSubEvent(source);
        }
    
        private void processSubEvent(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) {
                    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);
    
                        child.recycle();
                    }
                }
            }
        }
    }
    

    After processEvent() returns, helloSeen and helloAgainSeen will reflect whether your messages were encountered anywhere.

    0 讨论(0)
提交回复
热议问题