"Starting a blocking GC Explicit" looping

GerryHGerryH USMember ✭✭✭

I have been getting GC running in a loop:

11-23 10:30:28.228 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:28.261 I/art     ( 9736): Explicit concurrent mark sweep GC freed 3233(142KB) AllocSpace objects, 0(0B) LOS objects, 30% free, 36MB/52MB, paused 535us total 31.975ms
11-23 10:30:35.009 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:35.040 I/art     ( 9736): Explicit concurrent mark sweep GC freed 2648(76KB) AllocSpace objects, 0(0B) LOS objects, 30% free, 36MB/52MB, paused 355us total 31.012ms
11-23 10:30:38.071 I/Choreographer( 9736): Skipped 203 frames!  The application may be doing too much work on its main thread.
11-23 10:30:41.728 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:41.759 I/art     ( 9736): Explicit concurrent mark sweep GC freed 1589(54KB) AllocSpace objects, 0(0B) LOS objects, 30% free, 36MB/52MB, paused 353us total 31.224ms
11-23 10:30:44.106 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:44.138 I/art     ( 9736): Explicit concurrent mark sweep GC freed 1165(32KB) AllocSpace objects, 1(1688KB) LOS objects, 31% free, 34MB/50MB, paused 335us total 32.085ms
11-23 10:30:44.750 I/Choreographer( 9736): Skipped 175 frames!  The application may be doing too much work on its main thread.
11-23 10:30:45.347 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:45.379 I/art     ( 9736): Explicit concurrent mark sweep GC freed 586(22KB) AllocSpace objects, 0(0B) LOS objects, 31% free, 34MB/50MB, paused 480us total 31.144ms
Thread started: <Thread Pool> #27
11-23 10:30:46.504 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:46.535 I/art     ( 9736): Explicit concurrent mark sweep GC freed 1245(38KB) AllocSpace objects, 0(0B) LOS objects, 31% free, 34MB/50MB, paused 355us total 30.587ms
11-23 10:30:48.183 I/Choreographer( 9736): Skipped 202 frames!  The application may be doing too much work on its main thread.
11-23 10:30:48.405 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:48.436 I/art     ( 9736): Explicit concurrent mark sweep GC freed 215(8KB) AllocSpace objects, 0(0B) LOS objects, 31% free, 34MB/50MB, paused 501us total 31.104ms
11-23 10:30:49.718 I/art     ( 9736): Starting a blocking GC Explicit
11-23 10:30:49.749 I/art     ( 9736): Explicit concurrent mark sweep GC freed 1361(45KB) AllocSpace objects, 0(0B) LOS objects, 31% free, 34MB/50MB, paused 358us total 30.719ms

I have been trying to make performance/memory improvements, no luck. I have even started to comment out code so it does very little, yet still the garbage collector keeps running like a madman.

How do I find/fix the problem?

Posts

  • robbitrobbit CNMember Xamurai

    Please show your code

  • GerryHGerryH USMember ✭✭✭
    edited November 2018

    It seems like it was related to how I was sorting an ObservableCollection, probably. I was getting a lot of SignalR events causing the collection to sort a lot. Decided to not sort on 90% of the events as most don't change the order anyway. Switched sorting to something from stack overflow:

          internal static void Sort<T>(this ObservableCollection<T> collection, Comparison<T> comparison)
          {
             var sortableList = new List<T>(collection);
             sortableList.Sort(comparison);
    
             for (int i = 0; i < sortableList.Count; i++)
                collection.Move(collection.IndexOf(sortableList[i]), i);
          }
    

    Seems a bit old school, but most solutions want to create a new ObservableCollection which I believe is the wrong way to go, since it is tied to a view model.

Sign In or Register to comment.