-3

i have this JSON object i'm getting from an open socket:

{
 "action" : "login",
 "id" : "1554",
 "name": "asaf",
 "lat" : "26.519966",
 "long" : "-4.151437",
 "radius":"0", 
  "data":[
          {"id":"12345"},
          {"id":"1234"},
          {"id":"123"}
         ]
}

inside my code when i'm doing:

stream = new JSONObject(input);

(input is my object from the socket) i'm getting the java.lang.OutOfMemoryError java Heap..

can't really understand why...

stacktrace:

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)
3
  • 6
    post a stacktrace, please. Commented May 21, 2012 at 8:20
  • Please write your complete code. Commented May 21, 2012 at 8:40
  • this it my complete code... line 80 at ServerWorker is stream = new JSONObject(input); Commented May 21, 2012 at 8:44

1 Answer 1

1

probably you can do like this if your JSON response is large:

stream = new JSONObject(new JSONTokener(input)):
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.