1

I want to fetch all my json child so I could you my app offline. I do the syncing when my app first start. As it contains too much data in database my app got crashes many times and it's not able to fetch all data.

FATAL EXCEPTION: main Process: com.manish.firebaseexample, PID: 12234 java.lang.RuntimeException: Firebase Database encountered an OutOfMemoryError. You may need to reduce the amount of data you are syncing to the client (e.g. by using queries or syncing a deeper path). See https://firebase.google.com/docs/database/ios/structure-data#best_practices_for_data_structure and https://firebase.google.com/docs/database/android/retrieve-data#filtering_data at com.google.android.gms.internal.zzdyi.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.OutOfMemoryError at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94) at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145) at java.lang.StringBuilder.append(StringBuilder.java:216) at bma.toString(:com.google.android.gms.DynamiteModulesC@11746036:11) at bkq.a(:com.google.android.gms.DynamiteModulesC@11746036:82) at bkv.run(:com.google.android.gms.DynamiteModulesC@11746036:9) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841)

My Database Image

enter image description here

Varieties Details

 refDatabase = FirebaseDatabase.getInstance().getReference().child("INT").child("varieties");
    refDatabase.keepSynced(true);


    refDatabase.getRef().addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Log.d(TAG,""+dataSnapshot.toString());
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.d(TAG,databaseError.getMessage());
        }
    });

As "image" data contains the Base64 encoded image.

1
  • So expand a node in varieties and update/edit your question with how large is it? What does each one contain and how many are you trying to read at one time? Commented Nov 22, 2017 at 8:43

1 Answer 1

3

As the error message says, you're retrieving more data than can be expanded in your phone's memory. There are 2 ways for solving that.

  1. To free your phone's memory to hold more data.
  2. To filter data using one of the filtering methods.

Please see the offical documentation regarding filtering data within Firebase.

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

1 Comment

Another helpful answer, if this is not worked for anyone. stackoverflow.com/a/51175188/8123983

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.