A bug in the server caused it to send a single space as the response to a poll. This space was stored into a fixed-size 4MB string and passed to the json.org library, which finally OOMed. The string is variable-size and the maximum size was lowered to 2MB.
try{
final JSONArray array;
{
- final byte[] buf=new byte[4096*1024];
- inputStream.read(buf);
- array=new JSONArray(new String(buf));
+ final byte[] buf=new byte[2048*1024];
+ final int length=inputStream.read(buf);
+ array=new JSONArray(new String(buf, 0, length));
}
for(int i=0;i<array.length();i++){