Hello i have an android app
when an update ( Insert new data in firebase or update an attribute ) done in firebase the app will crash for 15-30 sec .
when i checked log , it show that's in that time the GC is working and it's take a lot of time to done his work so the app crashed a lot of time and in the phone you can't do anything till GC finish there work , i don't have so much data in my database also my application is not that bigger .
You can see the log here :
I/lhindeliveryma: Background concurrent copying GC freed 325485(8953KB) AllocSpace objects, 0(0B) LOS objects, 36% free, 10MB/16MB, paused 218us total 136.046ms
W/Looper: Slow Looper main: Long Msg: seq=1424 plan=02:06:39.877 late=2ms wall=2060ms running=1848ms runnable=39ms io=29ms h=android.os.Handler c=com.google.firebase.database.core.view.EventRaiser$1
I/lhindeliveryma: Background concurrent copying GC freed 373886(10MB) AllocSpace objects, 0(0B) LOS objects, 35% free, 11MB/17MB, paused 259us total 155.904ms
I/lhindeliveryma: Background concurrent copying GC freed 501873(13MB) AllocSpace objects, 0(0B) LOS objects, 33% free, 11MB/17MB, paused 394us total 247.891ms
I/lhindeliveryma: Background young concurrent copying GC freed 323701(8831KB) AllocSpace objects, 0(0B) LOS objects, 31% free, 12MB/17MB, paused 537us total 116.240ms
I/lhindeliveryma: Background concurrent copying GC freed 567601(15MB) AllocSpace objects, 0(0B) LOS objects, 32% free, 12MB/18MB, paused 430us total 288.562ms
I/lhindeliveryma: Background young concurrent copying GC freed 351662(9586KB) AllocSpace objects, 0(0B) LOS objects, 32% free, 12MB/18MB, paused 528us total 125.947ms
W/Looper: Slow Looper main: Long Msg: seq=1425 plan=02:06:40.037 late=1902ms wall=1811ms running=1692ms runnable=2ms h=android.os.Handler c=com.google.firebase.database.core.view.EventRaiser$1
I/Choreographer: Skipped 180 frames! The application may be doing too much work on its main thread.
here's what log is saying
and this is my code how i receive data from firebase :
FirebaseAuth mAuth;
mAuth = FirebaseAuth.getInstance();
FirebaseUser user = mAuth.getCurrentUser();
firebaseDatabase = FirebaseDatabase.getInstance();
EndLoop:
databaseReference = firebaseDatabase.getReference().child("Orders").child(City);
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
You = new ArrayList<>();
Now = new ArrayList<>();
postAd = new OrderAD();
boolean stop = false;
for (DataSnapshot postsnap : dataSnapshot.getChildren()) {
if(!stop)
for (DataSnapshot postsnap1 : postsnap.getChildren()) {
if(!stop)
for (DataSnapshot postsnap2 : postsnap1.getChildren()) {
if (!stop) {
Order post = postsnap2.getValue(Order.class);
if (!post.getStatus().equals("تم التوصيل") && !post.getStatus().equals("تم الغاء الطلب")) {
if (post.getDeliveryUID().equals(user.getUid()))
You.add(post);
else {
if (post.getDeliveryUID().equals("")) {
Now.add(post);
}
}
if (!Offers.contains(post.getKey())) {
Offers.add(post.getKey());
if (Done) {
show_Notification(post);
You.clear();
Now.clear();
stop = true;
System.out.println("Hello");
break;
}
}
}
break;
}
}
}
}
if(!Done){
Done = true;
}
Collections.sort(Now);
Collections.sort(You);
postAd = new OrderAD(Offers.this, Now);
recyclerView.setAdapter(postAd);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
any suggestion to solve this ?