1

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.

gorgi93
  • 2,457
  • 8
  • 30
  • 53
  • 1
    Check [my answer here](http://stackoverflow.com/a/14775184/995926). Does that help you? – rekire Jan 03 '17 at 19:56
  • it does. Any suggestion is welcome :) – gorgi93 Jan 03 '17 at 19:57
  • 1
    what is a message from server ? looks like you're trying to allocate very large string message, which causes a crash – Orest Savchak Jan 03 '17 at 20:23
  • I am not sure in that moment what is the message, but I can log the server response on the next crash. Message from server usually should just be normal size strings. But it might be a bug on the server side. Thanks for this idea – gorgi93 Jan 03 '17 at 20:27

1 Answers1

0

Try to add these lines in your manifest

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

it is working for some situations.

m 1987
  • 153
  • 2
  • 14
  • Adding `android:largeHeap="true"` in situations like these is hardly ever a good idea. http://www.codingthearchitecture.com/2008/01/14/jvm_lies_the_outofmemory_myth.html – Dayan Aug 22 '18 at 12:49