我有这个从打开的套接字获取的 JSON 对象:
{
"action" : "login",
"id" : "1554",
"name": "asaf",
"lat" : "26.519966",
"long" : "-4.151437",
"radius":"0",
"data":[
{"id":"12345"},
{"id":"1234"},
{"id":"123"}
]
}
当我在做的时候在我的代码里面:
stream = new JSONObject(input);
(输入是我来自套接字的对象)我得到了 java.lang.OutOfMemoryError java Heap ..
实在想不明白为什么……
堆栈跟踪:
Exception in thread "Worker for Socket: Socket[addr=/0:0:0:0:0:0:0:1,port=52571,localport=9001]" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.util.Arrays.copyOf(Unknown Source)
at java.util.ArrayList.ensureCapacity(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at org.json.JSONArray.<init>(JSONArray.java:117)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONObject.<init>(JSONObject.java:205)
at ServerWorker.run(ServerWorker.java:80)