0
        try {       
            Gson gson = new Gson();
            try
            {
                ((ProfileActivity)getActivity()).interactionResult = gson.fromJson(HomeCardString.toString(), InteractionSummaryResult.class);

            }
            catch(Exception e)
            {
                Log.i("myyyy", e.getMessage());
                e.printStackTrace();
            }

        } catch (Throwable t) {
            Log.e("My App", "Could not parse malformed JSON: \"" + responseString + "\"" + t.getMessage());
        }

gson.fromgson..... This line creating exception at Throwable t ..... The data which I have in HomeCardString.toString() is very big. about 1.9MB in a notepad file. I can't reduce the size of that data. What to do with that?

08-29 16:34:36.963: E/AndroidRuntime(29319): FATAL EXCEPTION: main
08-29 16:34:36.963: E/AndroidRuntime(29319): java.lang.OutOfMemoryError
08-29 16:34:36.963: E/AndroidRuntime(29319):    at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at java.lang.StringBuilder.append(StringBuilder.java:216)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at com.stalker.androidapp.InteractionTabFragment$ProfileInteractionCall.onPostExecute(InteractionTabFragment.java:175)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at com.stalker.androidapp.InteractionTabFragment$ProfileInteractionCall.onPostExecute(InteractionTabFragment.java:1)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at android.os.AsyncTask.finish(AsyncTask.java:602)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at android.os.AsyncTask.access$600(AsyncTask.java:156)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at android.os.Looper.loop(Looper.java:137)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at android.app.ActivityThread.main(ActivityThread.java:4448)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at java.lang.reflect.Method.invokeNative(Native Method)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at java.lang.reflect.Method.invoke(Method.java:511)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
08-29 16:34:36.963: E/AndroidRuntime(29319):    at dalvik.system.NativeStart.main(Native Method)
1
  • Why can't you reduce the size of the data? 1.9 MB for JSON data is...excessive, to say the least. Commented Aug 29, 2014 at 11:48

2 Answers 2

3

You can try setting android:largeHeap="true" for your application in the manifest. Here is the reference:

http://developer.android.com/reference/android/R.styleable.html#AndroidManifestApplication_largeHeap

If this doesn't work, have a look at this post:

JAVA - Best approach to parse huge (extra large) JSON file

Sign up to request clarification or add additional context in comments.

Comments

0

Change

        Log.e("My App", "Could not parse malformed JSON: \"" + responseString + "\"" + t.getMessage());

to

        String res = responseString.length() > 160 
            ? responseString.substring(0, 40) + "..." : responseString;
        Log.e("My App", "Could not parse malformed JSON: \"" + res + "\":\n" + t.getMessage());

as logging is not critical.

1 Comment

Thats helpful but I was in search of something Bruno has shared

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.