title: App crash with GC When an object added to firebase - Android Studio
body: <p>Hello i have an android app</p>
  <p>when an update ( Insert new data in firebase or update an attribute )  done in firebase the app will crash for 15-30 sec .</p>
  <p>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 .</p>
  <p>You can see the log here :</p>
  <pre><code>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.
  </code></pre>
  <p>here's what log is saying</p>
  <p>and this is my code how i receive data from firebase :</p>
  <pre><code>
          FirebaseAuth mAuth;
          mAuth = FirebaseAuth.getInstance();
  
          FirebaseUser user = mAuth.getCurrentUser();
  
  
          firebaseDatabase = FirebaseDatabase.getInstance();
  
  
          EndLoop:
          databaseReference = firebaseDatabase.getReference().child(&quot;Orders&quot;).child(City);
          databaseReference.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  
  
  
  
                  You = new ArrayList&lt;&gt;();
                  Now = new ArrayList&lt;&gt;();
  
  
                  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(&quot;تم التوصيل&quot;) &amp;&amp; !post.getStatus().equals(&quot;تم الغاء الطلب&quot;)) {
  
  
  
  
                                      if (post.getDeliveryUID().equals(user.getUid()))
                                          You.add(post);
                                      else {
                                          if (post.getDeliveryUID().equals(&quot;&quot;)) {
                                              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(&quot;Hello&quot;);
                                              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) {
  
              }
          });
  
  </code></pre>
  <p>any suggestion to solve this ?</p>