Reputation: 41
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
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.
Upvotes: 1
Views: 3967
Reputation: 138824
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.
- To free your phone's memory to hold more data.
- To filter data using one of the filtering methods.
Please see the offical documentation regarding filtering data within Firebase.
Upvotes: 3