RadCartesianChart and NumericalAxis - 46080 outstanding GREFs. Performing a full GC

2 Answers 522 Views
Chart Chart - Xamarin.Android
Davide
Top achievements
Rank 1
Iron
Davide asked on 28 Mar 2022, 02:06 PM

Hello everyone,

I'm implementing a real-time chart to draw a scatter plot using as points two signals (each signal has a sampling frequency of 25 Hz). Every seconds I update the plot with the latest 25 points that I receive from a Bluetooth device. 

To do this, I use as horizontal and vertical axis two NumericalAxis.

<telerikChart:RadCartesianChart.HorizontalAxis>
	<telerikChart:NumericalAxis
		LabelTextColor="{AppThemeBinding Light={StaticResource TextColorWithLightBackground}, Dark={StaticResource TextColorWithDarkBackground}}"
		MajorStep="{Binding MajorStepX}"
		Maximum="{Binding MaxValueX}"
		Minimum="{Binding MinValueX}"
		RangeExtendDirection="Both"
		ShowLabels="True" />
</telerikChart:RadCartesianChart.HorizontalAxis>

<telerikChart:RadCartesianChart.VerticalAxis>
	<telerikChart:NumericalAxis
		LabelTextColor="{AppThemeBinding Light={StaticResource TextColorWithLightBackground}, Dark={StaticResource TextColorWithDarkBackground}}"
		MajorStep="{Binding MajorStepZ}"
		Maximum="{Binding MaxValueZ}"
		Minimum="{Binding MinValueZ}"
		RangeExtendDirection="Both"
		ShowLabels="True" />
</telerikChart:RadCartesianChart.VerticalAxis>

In order to draw the scatter plot I use ScatterSplineSeries as follow:

<telerikChart:RadCartesianChart.Series>
	<telerikChart:ScatterSplineSeries
		ItemsSource="{Binding SwayProjection}"
		Stroke="{StaticResource AccentColor}"
		XValueBinding="ValueX"
		YValueBinding="ValueZ"/>
</telerikChart:RadCartesianChart.Series>

The variable that I bind to the xaml code is an ObservableCollection

private ObservableCollection<Sway> swayProjection;
public ObservableCollection<Sway> SwayProjection
{
     get => swayProjection;
     set => Set(ref swayProjection, value);
}

public class Sway
{
	public double ValueX { get; set; }

	public double ValueZ { get; set; }

	public Sway(double valueX = 0, double valueZ = 0)
	{
		ValueX = valueX;

		ValueZ = valueZ;
	}
}

When I run the real-time visualization, the application seems fine till the free Garbage Collector memory starts to decrease, and when the memory is full the application stops working, it does not respond to any input. The crash happens after 2 minutes I open the chart.

Here the output during debug:

Explicit concurrent copying GC freed 54001(1408KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 11MB/22MB, paused 103us total 96.085ms
 Explicit concurrent copying GC freed 37609(991KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 11MB/22MB, paused 97us total 96.957ms
 Explicit concurrent copying GC freed 53557(1390KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 11MB/23MB, paused 125us total 108.540ms
 Explicit concurrent copying GC freed 53581(1405KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 12MB/24MB, paused 136us total 116.409ms
 Explicit concurrent copying GC freed 37643(1151KB) AllocSpace objects, 0(0B) LOS objects, 48% free, 12MB/24MB, paused 132us total 118.569ms
 Explicit concurrent copying GC freed 53218(1373KB) AllocSpace objects, 0(0B) LOS objects, 47% free, 13MB/25MB, paused 136us total 122.932ms
 Explicit concurrent copying GC freed 37110(1008KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 13MB/25MB, paused 129us total 122.942ms
 Explicit concurrent copying GC freed 39885(1059KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 13MB/25MB, paused 89us total 119.415ms
 Explicit concurrent copying GC freed 50296(1335KB) AllocSpace objects, 0(0B) LOS objects, 45% free, 14MB/26MB, paused 92us total 121.345ms
 Explicit concurrent copying GC freed 53232(1393KB) AllocSpace objects, 0(0B) LOS objects, 45% free, 14MB/26MB, paused 89us total 126.493ms
Thread started:  #20
 Explicit concurrent copying GC freed 37745(1016KB) AllocSpace objects, 0(0B) LOS objects, 44% free, 14MB/26MB, paused 105us total 129.328ms
 Explicit concurrent copying GC freed 53039(1361KB) AllocSpace objects, 0(0B) LOS objects, 43% free, 15MB/27MB, paused 90us total 132.925ms
 Explicit concurrent copying GC freed 40331(1060KB) AllocSpace objects, 0(0B) LOS objects, 43% free, 15MB/27MB, paused 96us total 134.657ms
 Explicit concurrent copying GC freed 50412(1336KB) AllocSpace objects, 0(0B) LOS objects, 42% free, 16MB/28MB, paused 138us total 144.375ms
 Explicit concurrent copying GC freed 40573(1077KB) AllocSpace objects, 0(0B) LOS objects, 42% free, 16MB/28MB, paused 129us total 156.344ms
 Explicit concurrent copying GC freed 50866(1317KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 137us total 155.731ms
 Explicit concurrent copying GC freed 36935(1008KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 87us total 148.042ms
 Explicit concurrent copying GC freed 3790(174KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 89us total 146.685ms
 Explicit concurrent copying GC freed 6140(190KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 93us total 145.927ms
Thread started:  #21
 Explicit concurrent copying GC freed 8523(291KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 90us total 147.018ms
 Explicit concurrent copying GC freed 4160(171KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 154us total 165.773ms
[Choreographer] Skipped 34 frames!  The application may be doing too much work on its main thread.
 Explicit concurrent copying GC freed 5686(207KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 87us total 148.642ms
Thread started:  #22
 Explicit concurrent copying GC freed 8239(291KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 87us total 148.701ms
 Explicit concurrent copying GC freed 3547(118KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 87us total 149.489ms
 Explicit concurrent copying GC freed 1524(65KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 93us total 148.620ms
 Explicit concurrent copying GC freed 2017(92KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 99us total 150.422ms
[Choreographer] Skipped 75 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=1280ms; Flags=0, IntendedVsync=259755680782292, Vsync=259756930782242, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259756931310244, AnimationStart=259756931314168, PerformTraversalsStart=259756931316091, DrawStart=259756940541437, SyncQueued=259756946356668, SyncStart=259756947254360, IssueDrawCommandsStart=259756948458783, SwapBuffers=259756959868129, FrameCompleted=259756961742821, DequeueBufferDuration=648115, QueueBufferDuration=706538, GpuCompleted=259691497209253, 
 Explicit concurrent copying GC freed 10564(315KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 89us total 150.219ms
 Explicit concurrent copying GC freed 5088(148KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 97us total 151.665ms
 Explicit concurrent copying GC freed 11824(330KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 89us total 152.310ms
[monodroid-gc] 46080 outstanding GREFs. Performing a full GC!
 Explicit concurrent copying GC freed 21960(978KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 110us total 148.285ms
Thread started:  #23
Thread started: <Thread Pool> #24
Thread started: <Thread Pool> #25
 Explicit concurrent copying GC freed 4495(218KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 92us total 144.743ms
[Choreographer] Skipped 178 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=3000ms; Flags=0, IntendedVsync=259757682371890, Vsync=259760649038438, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259760657666550, AnimationStart=259760657669280, PerformTraversalsStart=259760657670626, DrawStart=259760661536549, SyncQueued=259760665160473, SyncStart=259760665820819, IssueDrawCommandsStart=259760666742819, SwapBuffers=259760679965934, FrameCompleted=259760683168857, DequeueBufferDuration=411962, QueueBufferDuration=2081000, GpuCompleted=259693826313597, 
 Explicit concurrent copying GC freed 6209(182KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 123us total 146.406ms
 Explicit concurrent copying GC freed 8105(295KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 91us total 146.014ms
 Explicit concurrent copying GC freed 2375(98KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 90us total 146.947ms
 Explicit concurrent copying GC freed 1624(73KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 87us total 145.344ms
 Explicit concurrent copying GC freed 2334(94KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 16MB/28MB, paused 96us total 146.540ms
[Choreographer] Skipped 71 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=1218ms; Flags=0, IntendedVsync=259760929756570, Vsync=259762113089856, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259762126559818, AnimationStart=259762126563395, PerformTraversalsStart=259762126564548, DrawStart=259762130274548, SyncQueued=259762132692010, SyncStart=259762133975125, IssueDrawCommandsStart=259762135384433, SwapBuffers=259762147486587, FrameCompleted=259762149105087, DequeueBufferDuration=850847, QueueBufferDuration=729846, GpuCompleted=259695480535365, 
 Explicit concurrent copying GC freed 12465(349KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 92us total 147.570ms
 Explicit concurrent copying GC freed 1804(113KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 98us total 147.534ms
[Choreographer] Skipped 47 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=808ms; Flags=0, IntendedVsync=259762196173073, Vsync=259762979506375, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259762982768817, AnimationStart=259762982772048, PerformTraversalsStart=259762982773240, DrawStart=259762986505202, SyncQueued=259762989613125, SyncStart=259762990501586, IssueDrawCommandsStart=259762991509317, SwapBuffers=259763003695702, FrameCompleted=259763005409932, DequeueBufferDuration=554692, QueueBufferDuration=627500, GpuCompleted=259695529888327, 
 Explicit concurrent copying GC freed 5908(174KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 95us total 148.675ms
 Explicit concurrent copying GC freed 8677(268KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 91us total 147.561ms
 Explicit concurrent copying GC freed 2097(91KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 90us total 148.625ms
 Explicit concurrent copying GC freed 2454(87KB) AllocSpace objects, 0(0B) LOS objects, 41% free, 17MB/29MB, paused 96us total 149.302ms
 Explicit concurrent copying GC freed 6080(146KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 155us total 153.549ms
 Explicit concurrent copying GC freed 7544(253KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 103us total 149.711ms
 Explicit concurrent copying GC freed 2263(100KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 87us total 150.617ms
 Explicit concurrent copying GC freed 1884(90KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 91us total 150.828ms
 Explicit concurrent copying GC freed 5253(143KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 99us total 152.274ms
 Explicit concurrent copying GC freed 9370(293KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 88us total 152.580ms
 WaitForGcToComplete blocked HeapTrim on HeapTrim for 113.879ms
 Explicit concurrent copying GC freed 2924(95KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 86us total 152.194ms
[Choreographer] Skipped 64 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=1112ms; Flags=0, IntendedVsync=259766080396331, Vsync=259767147062955, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259767157555199, AnimationStart=259767157558660, PerformTraversalsStart=259767157560237, DrawStart=259767161963160, SyncQueued=259767165363122, SyncStart=259767167661429, IssueDrawCommandsStart=259767169690276, SwapBuffers=259767192783083, FrameCompleted=259767195062814, DequeueBufferDuration=871500, QueueBufferDuration=890423, GpuCompleted=259697348532518, 
 Explicit concurrent copying GC freed 2767(96KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 92us total 154.368ms
 Explicit concurrent copying GC freed 10723(323KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 89us total 154.010ms
 Explicit concurrent copying GC freed 3175(116KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 95us total 151.236ms
 Explicit concurrent copying GC freed 1914(100KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 97us total 152.201ms
[Choreographer] Skipped 69 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=1184ms; Flags=0, IntendedVsync=259767345916285, Vsync=259768495916239, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259768505676198, AnimationStart=259768505679275, PerformTraversalsStart=259768505680621, DrawStart=259768509933005, SyncQueued=259768513841467, SyncStart=259768514441928, IssueDrawCommandsStart=259768515314852, SwapBuffers=259768529545544, FrameCompleted=259768531037890, DequeueBufferDuration=359039, QueueBufferDuration=625423, GpuCompleted=259697745192902, 
 Explicit concurrent copying GC freed 11713(341KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 91us total 154.326ms
 Explicit concurrent copying GC freed 3475(107KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 90us total 153.946ms
 Explicit concurrent copying GC freed 1556(75KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 91us total 153.783ms
[Choreographer] Skipped 66 frames!  The application may be doing too much work on its main thread.
 Explicit concurrent copying GC freed 2085(86KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 92us total 155.068ms
[OpenGLRenderer] Davey! duration=1315ms; Flags=0, IntendedVsync=259768529240526, Vsync=259769629240482, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259769636190158, AnimationStart=259769636193774, PerformTraversalsStart=259769636195274, DrawStart=259769805658197, SyncQueued=259769819669312, SyncStart=259769821524043, IssueDrawCommandsStart=259769823533197, SwapBuffers=259769845143043, FrameCompleted=259769846971543, DequeueBufferDuration=1190192, QueueBufferDuration=710385, GpuCompleted=259698033340825, 
 Explicit concurrent copying GC freed 11329(324KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 94us total 156.586ms
 Explicit concurrent copying GC freed 3044(96KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 97us total 155.286ms
 Explicit concurrent copying GC freed 1218(84KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 198us total 198.457ms
[Choreographer] Skipped 82 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=1416ms; Flags=0, IntendedVsync=259769862825707, Vsync=259771229492319, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259771246019542, AnimationStart=259771246022888, PerformTraversalsStart=259771246024042, DrawStart=259771250091388, SyncQueued=259771253344003, SyncStart=259771254218388, IssueDrawCommandsStart=259771255703311, SwapBuffers=259771278216850, FrameCompleted=259771280275119, DequeueBufferDuration=872346, QueueBufferDuration=799077, GpuCompleted=259699580866901, 
 Explicit concurrent copying GC freed 2861(144KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 93us total 156.503ms
Thread started:  #26
 Explicit concurrent copying GC freed 10130(291KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 92us total 157.316ms
 Explicit concurrent copying GC freed 2186(99KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 90us total 156.936ms
 WaitForGcToComplete blocked HeapTrim on HeapTrim for 139.886ms
 Explicit concurrent copying GC freed 1817(96KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 89us total 158.241ms
Thread started:  #27
[monodroid-gc] 46080 outstanding GREFs. Performing a full GC!
 Explicit concurrent copying GC freed 7884(366KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 111us total 157.799ms
Thread started:  #28
[Choreographer] Skipped 228 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=3829ms; Flags=0, IntendedVsync=259771262632157, Vsync=259775062632005, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259775069390385, AnimationStart=259775069393578, PerformTraversalsStart=259775069394693, DrawStart=259775072466808, SyncQueued=259775075405501, SyncStart=259775076655193, IssueDrawCommandsStart=259775077766655, SwapBuffers=259775091314693, FrameCompleted=259775093159731, DequeueBufferDuration=558885, QueueBufferDuration=665462, GpuCompleted=259699626355785, 
 Explicit concurrent copying GC freed 14246(407KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 90us total 157.501ms
 Explicit concurrent copying GC freed 3151(117KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 96us total 155.908ms
 Explicit concurrent copying GC freed 2896(104KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 93us total 155.947ms
[Choreographer] Skipped 54 frames!  The application may be doing too much work on its main thread.
[OpenGLRenderer] Davey! duration=940ms; Flags=0, IntendedVsync=259775145639729, Vsync=259776045639693, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=259776062107808, AnimationStart=259776062111692, PerformTraversalsStart=259776062113808, DrawStart=259776069209269, SyncQueued=259776072746962, SyncStart=259776073519885, IssueDrawCommandsStart=259776074474846, SwapBuffers=259776084769231, FrameCompleted=259776086417731, DequeueBufferDuration=507192, QueueBufferDuration=666539, GpuCompleted=259700829677131, 
 Explicit concurrent copying GC freed 11216(340KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 89us total 157.274ms
 Explicit concurrent copying GC freed 2596(103KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 100us total 159.401ms

This event does not happen if one of the two axis is CategoricalAxis.I run a test where I left the real-time chart opened for 8 minutes.

Did everyone experience similar trouble? Is there any workaround to avoid the application crash?
I had the opportunity to see this behavior in my app only on Android.

Thanks in advance.

 

 

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 29 Mar 2022, 11:48 AM

Hi Davide,

Thank you for explaining the scenario.  Actually this is a bit of expected - mobile platforms have some memory limitations and it seems you've reached the limit.  What I would suggest is at some point to remove the first points before adding the new coming points - in this way the Chart wouldn't need to handle all the amount of points at once.  Also you do not need the initial points - as the data is updated so quickly, it will be impossible for the user to scroll back to the first data.

Please give it a try and let me know what you think of this approach.

Regards,
Yana
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Davide
Top achievements
Rank 1
Iron
answered on 30 Mar 2022, 02:02 PM

Hi Yana,

thank you for the advice. When I posted the question, I had already implemented some sort of buffer; when I reach a certain amount of data, I delete the oldest data and update the buffer with the newest data that I have received from the sensor.

The implementation is the following:

SwayProjection = new ObservableCollection<Sway>((SwayProjection ?? new ObservableCollection<Sway>())
                .Skip(measureCountPostureAnalysis >= maxMeasureCount ? x.Length : 0).Union(swayTmp));

I can try to decrease the number of seconds plotted in the chart, reducing the value maxMeasureCount. 

If you have any other suggestions, they are welcome!

Best,

Davide

Tags
Chart Chart - Xamarin.Android
Asked by
Davide
Top achievements
Rank 1
Iron
Answers by
Yana
Telerik team
Davide
Top achievements
Rank 1
Iron
Share this question
or