Android Out of Memory

501 views Asked by At

I have a weird out of memory problem that I can not solve. I believe I might have a problem in websocket handling but I am not sure why or where. I have tried to take memory dump with Android Monitor but I can not seem to catch the problem. I have tried adding android:largeHeap="true" flag.

I have no idea where to go from there and how to fight this problem or what to check. Do you have any suggestions to what I can do? I use firebase for production error logging where I also receive this error stacks when the error happens:

Exception java.lang.OutOfMemoryError: Failed to allocate a 916 byte allocation with 8388608 free bytes and 369MB until OOM; failed due to fragmentation (required continguous free 65536 bytes for a new buffer where largest contiguous free 32768 bytes)
java.nio.CharBuffer.allocate (CharBuffer.java:54)
java.nio.charset.CharsetDecoder.allocateMore (CharsetDecoder.java:226)
java.nio.charset.CharsetDecoder.decode (CharsetDecoder.java:188)
org.java_websocket.util.Charsetfunctions.stringUtf8 (Charsetfunctions.java:77)
org.java_websocket.WebSocketImpl.decodeFrames (WebSocketImpl.java:375)
org.java_websocket.WebSocketImpl.decode (WebSocketImpl.java:158)
org.java_websocket.client.WebSocketClient.run (WebSocketClient.java:185)
java.lang.Thread.run (Thread.java:818)

I understand this question is vague but I would appreciate just suggestions to where to go next.

1

There are 1 answers

1
m 1987 On

Try to add these lines in your manifest

android:hardwareAccelerated="false" , android:largeHeap="true"

it is working for some situations.