Reuse Handler when invoking on main thread #383

Merged
merged 1 commit into from Sep 27, 2016

Conversation

Projects
None yet
5 participants
@hartez
Member

hartez commented Sep 26, 2016

Description of Change

Currently, every time Device.BeginInvokeOnMainThread() is called on a Android device, a new instance of Handler is created to post the action to the main thread. This means that every time a bound property is changed, a new instance of Handler is created; this creates additional GC pressure, especially during floods of property changes.

This change reuses the Handler each time rather than creating a new one, significantly reducing the number of objects allocated as a result of property changes.

@StephaneDelcroix

This comment has been minimized.

Show comment
Hide comment
@StephaneDelcroix

StephaneDelcroix Sep 27, 2016

Member

What if the handler is already executing an action ? Does it queue them ? or should we ?

Member

StephaneDelcroix commented Sep 27, 2016

What if the handler is already executing an action ? Does it queue them ? or should we ?

@hartez

This comment has been minimized.

Show comment
Hide comment

@jassmith jassmith merged commit 0f7b22f into master Sep 27, 2016

4 of 5 checks passed

iOS10-UITests Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle8 :: UI Tests :: OSX Test Cloud Package - Run iOS Unified iOS10 : Exit code 15 (new)
Details
Android-UITests Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle8 :: UI Tests :: OSX Test Cloud Package - Run Android 6.0.1 : Tests passed: 346, ig…
Details
OSX-Debug-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle8 :: OSX Debug : Running
Details
Windows-Debug-C8 Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle8 :: Windows Debug : Running
Details
iOS9-UITests Finished TeamCity Build Xamarin.Forms :: Debug :: Cycle8 :: UI Tests :: OSX Test Cloud Package - Run iOS Unified iOS9 : Tests passed: 342,…
Details

@rmarinho rmarinho deleted the android-reuse-handler branch Oct 7, 2016

@samhouts samhouts added this to the 2.3.4 milestone Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment