Bug 20738 - "Out of memory" error when implementing a button, building to device and rotating screen multiple times
Summary: "Out of memory" error when implementing a button, building to device and rota...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.0.6188
Hardware: PC Mac OS
: --- normal
Target Milestone: 1.3.4
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-06-19 18:17 UTC by Jessica Steger
Modified: 2015-02-13 05:28 UTC (History)
11 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Small reproduction solution for memory leak using Button objects with a set BackgroundColor on Android (30.81 KB, application/octet-stream)
2015-02-11 09:05 UTC, David Catteuw
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Jessica Steger 2014-06-19 18:17:19 UTC
If we try to add a backgroundcolor to a button (see following code…) we get an out of memory error if we turn our phone from landscape to portrait and back again!
 
This code works fine…
public static Page GetMainPage()
        {
            return (new ContentPage
            {
                Content = new Button
                {
                    Text = "Click me!",
                    //BackgroundColor = Color.Red,
                },
            });
        }
 
06-17 15:28:16.467 D/Mono    (11397): Assembly Ref addref System.Xml[0x7f033df8] -> mscorlib[0x728132f8]: 59
06-17 15:28:19.840 E/MoreInfoHPW_ViewGroup(11397): Parent view is not a TextView
06-17 15:28:19.870 E/ViewRootImpl(11397): sendUserActionEvent() mView == null
06-17 15:28:21.932 E/MoreInfoHPW_ViewGroup(11397): Parent view is not a TextView
06-17 15:28:21.952 E/ViewRootImpl(11397): sendUserActionEvent() mView == null
06-17 15:28:36.176 E/MoreInfoHPW_ViewGroup(11397): Parent view is not a TextView
06-17 15:28:36.196 E/ViewRootImpl(11397): sendUserActionEvent() mView == null
06-17 15:28:37.247 E/MoreInfoHPW_ViewGroup(11397): Parent view is not a TextView
06-17 15:28:37.267 E/ViewRootImpl(11397): sendUserActionEvent() mView == null
 
But this one throws an error.. if you turn your phone multiple times!
 
        public static Page GetMainPage()
        {
            return (new ContentPage
            {
                Content = new Button
                {
                    Text = "Click me!",
                    BackgroundColor = Color.Red,
                },
            });
        }
 
06-17 15:30:17.314 D/Mono    (13233): Assembly Ref addref System.Xml[0x7f034f00] -> mscorlib[0x728132f8]: 59
06-17 15:30:17.815 D/dalvikvm(13233): GC_FOR_ALLOC freed 120K, 17% free 21930K/26348K, paused 26ms, total 27ms
06-17 15:30:17.845 I/dalvikvm-heap(13233): Grow heap (frag case) to 31.941MB for 7970416-byte allocation
06-17 15:30:17.855 D/dalvikvm(13233): GC_CONCURRENT freed 17K, 13% free 29697K/34132K, paused 2ms+2ms, total 17ms
06-17 15:30:17.915 D/dalvikvm(13233): GC_FOR_ALLOC freed <1K, 13% free 29697K/34132K, paused 18ms, total 18ms
06-17 15:30:19.847 E/MoreInfoHPW_ViewGroup(13233): Parent view is not a TextView
06-17 15:30:19.877 E/ViewRootImpl(13233): sendUserActionEvent() mView == null
06-17 15:30:19.947 D/dalvikvm(13233): GC_FOR_ALLOC freed 20K, 11% free 37556K/41916K, paused 16ms, total 16ms
06-17 15:30:19.957 I/dalvikvm-heap(13233): Grow heap (frag case) to 46.960MB for 7718416-byte allocation
06-17 15:30:19.977 D/dalvikvm(13233): GC_CONCURRENT freed 14K, 9% free 45080K/49456K, paused 2ms+2ms, total 17ms
06-17 15:30:19.977 D/dalvikvm(13233): WAIT_FOR_CONCURRENT_GC blocked 12ms
06-17 15:30:19.987 I/dalvikvm-heap(13233): Grow heap (frag case) to 54.307MB for 7718416-byte allocation
06-17 15:30:20.668 E/MoreInfoHPW_ViewGroup(13233): Parent view is not a TextView
06-17 15:30:20.698 E/ViewRootImpl(13233): sendUserActionEvent() mView == null
06-17 15:30:20.768 D/dalvikvm(13233): GC_FOR_ALLOC freed 21K, 8% free 52690K/56996K, paused 15ms, total 15ms
06-17 15:30:20.778 I/dalvikvm-heap(13233): Grow heap (frag case) to 61.980MB for 7970416-byte allocation
06-17 15:30:20.798 D/dalvikvm(13233): GC_FOR_ALLOC freed 6K, 7% free 60467K/64780K, paused 15ms, total 15ms
06-17 15:30:20.808 I/dalvikvm-heap(13233): Grow heap (frag case) to 69.575MB for 7970416-byte allocation
06-17 15:30:21.438 E/MoreInfoHPW_ViewGroup(13233): Parent view is not a TextView
06-17 15:30:21.458 E/ViewRootImpl(13233): sendUserActionEvent() mView == null
06-17 15:30:21.529 D/dalvikvm(13233): GC_FOR_ALLOC freed 29K, 6% free 68316K/72564K, paused 17ms, total 17ms
06-17 15:30:21.539 I/dalvikvm-heap(13233): Grow heap (frag case) to 77.000MB for 7718416-byte allocation
06-17 15:30:21.559 D/dalvikvm(13233): GC_FOR_ALLOC freed 15K, 6% free 75838K/80104K, paused 15ms, total 15ms
06-17 15:30:21.569 I/dalvikvm-heap(13233): Grow heap (frag case) to 84.345MB for 7718416-byte allocation
06-17 15:30:22.279 E/MoreInfoHPW_ViewGroup(13233): Parent view is not a TextView
06-17 15:30:22.299 E/ViewRootImpl(13233): sendUserActionEvent() mView == null
06-17 15:30:22.369 D/dalvikvm(13233): GC_FOR_ALLOC freed 21K, 5% free 83449K/87644K, paused 17ms, total 17ms
06-17 15:30:22.379 I/dalvikvm-heap(13233): Grow heap (frag case) to 92.018MB for 7970416-byte allocation
06-17 15:30:22.399 D/dalvikvm(13233): GC_FOR_ALLOC freed 15K, 5% free 91218K/95428K, paused 16ms, total 16ms
06-17 15:30:22.409 I/dalvikvm-heap(13233): Grow heap (frag case) to 99.605MB for 7970416-byte allocation
06-17 15:30:23.410 E/MoreInfoHPW_ViewGroup(13233): Parent view is not a TextView
06-17 15:30:23.440 E/ViewRootImpl(13233): sendUserActionEvent() mView == null
06-17 15:30:23.500 D/dalvikvm(13233): GC_FOR_ALLOC freed 21K, 5% free 99075K/103212K, paused 17ms, total 17ms
06-17 15:30:23.520 I/dalvikvm-heap(13233): Grow heap (frag case) to 107.038MB for 7718416-byte allocation
06-17 15:30:23.541 D/dalvikvm(13233): GC_FOR_ALLOC freed 15K, 4% free 106598K/110752K, paused 17ms, total 18ms
06-17 15:30:23.551 I/dalvikvm-heap(13233): Grow heap (frag case) to 114.384MB for 7718416-byte allocation
06-17 15:30:24.171 E/MoreInfoHPW_ViewGroup(13233): Parent view is not a TextView
06-17 15:30:24.201 E/ViewRootImpl(13233): sendUserActionEvent() mView == null
06-17 15:30:24.261 D/dalvikvm(13233): GC_FOR_ALLOC freed 21K, 4% free 114209K/118292K, paused 17ms, total 17ms
06-17 15:30:24.281 I/dalvikvm-heap(13233): Grow heap (frag case) to 122.057MB for 7970416-byte allocation
06-17 15:30:24.301 I/dalvikvm-heap(13233): Clamp target GC heap from 128.042MB to 128.000MB
06-17 15:30:24.301 D/dalvikvm(13233): GC_FOR_ALLOC freed 15K, 4% free 121978K/126076K, paused 18ms, total 18ms
06-17 15:30:24.301 I/dalvikvm-heap(13233): Forcing collection of SoftReferences for 7970416-byte allocation
06-17 15:30:24.331 I/dalvikvm-heap(13233): Clamp target GC heap from 132.035MB to 128.000MB
06-17 15:30:24.331 D/dalvikvm(13233): GC_BEFORE_OOM freed 14K, 4% free 121964K/126076K, paused 28ms, total 28ms
06-17 15:30:24.331 E/dalvikvm-heap(13233): Out of memory on a 7970416-byte allocation.
06-17 15:30:24.331 I/dalvikvm(13233): "main" prio=5 tid=1 RUNNABLE
06-17 15:30:24.331 I/dalvikvm(13233):   | group="main" sCount=0 dsCount=0 obj=0x41877ea0 self=0x41771a48
06-17 15:30:24.331 I/dalvikvm(13233):   | sysTid=13233 nice=0 sched=0/0 cgrp=apps handle=1074348372
06-17 15:30:24.331 I/dalvikvm(13233):   | state=R schedstat=( 0 0 0 ) utm=244 stm=61 core=2
06-17 15:30:24.331 I/dalvikvm(13233):   at android.graphics.Bitmap.nativeCreate(Native Method)
06-17 15:30:24.331 I/dalvikvm(13233):   at android.graphics.Bitmap.createBitmap(Bitmap.java:903)
06-17 15:30:24.331 I/dalvikvm(13233):   at android.graphics.Bitmap.createBitmap(Bitmap.java:880)
06-17 15:30:24.331 I/dalvikvm(13233):   at android.graphics.Bitmap.createBitmap(Bitmap.java:847)
06-17 15:30:24.331 I/dalvikvm(13233):   at xamarin.forms.platform.android.ButtonDrawable.n_draw(Native Method)
06-17 15:30:24.331 I/dalvikvm(13233):   at xamarin.forms.platform.android.ButtonDrawable.draw(ButtonDrawable.java:49)
06-17 15:30:24.331 I/dalvikvm(13233):   at android.view.View.draw(View.java:15288)
06-17 15:30:24.331 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14197)
06-17 15:30:24.331 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.331 I/dalvikvm(13233):   at android.view.View.draw(View.java:15017)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3142)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14192)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.draw(View.java:15017)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3142)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14192)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.draw(View.java:15017)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14192)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.draw(View.java:15017)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14192)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.draw(View.java:15017)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14192)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.draw(View.java:15017)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14192)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.draw(View.java:15017)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.drawChild(ViewGroup.java:3298)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3135)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.draw(View.java:15306)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.widget.FrameLayout.draw(FrameLayout.java:472)
06-17 15:30:24.341 I/dalvikvm(13233):   at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2568)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14197)
06-17 15:30:24.341 I/dalvikvm(13233):   at android.view.View.getDisplayList(View.java:14239)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.ViewRootImpl.draw(ViewRootImpl.java:2703)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2569)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2141)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1234)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6465)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.Choreographer.doCallbacks(Choreographer.java:603)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.Choreographer.doFrame(Choreographer.java:573)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.os.Handler.handleCallback(Handler.java:733)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.os.Handler.dispatchMessage(Handler.java:95)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.os.Looper.loop(Looper.java:157)
06-17 15:30:24.351 I/dalvikvm(13233):   at android.app.ActivityThread.main(ActivityThread.java:5356)
06-17 15:30:24.351 I/dalvikvm(13233):   at java.lang.reflect.Method.invokeNative(Native Method)
06-17 15:30:24.351 I/dalvikvm(13233):   at java.lang.reflect.Method.invoke(Method.java:515)
06-17 15:30:24.351 I/dalvikvm(13233):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
06-17 15:30:24.351 I/dalvikvm(13233):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
06-17 15:30:24.351 I/dalvikvm(13233):   at dalvik.system.NativeStart.main(Native Method)
06-17 15:30:24.351 I/dalvikvm(13233):
An unhandled exception occured.
Comment 1 Eric Maupin 2014-07-16 13:36:41 UTC
Fixed in 1.2
Comment 2 Jon Douglas [MSFT] 2014-11-12 16:25:10 UTC
Have a customer running Xamarin Forms 1.2.3 running into this issue:

Reproduction: https://www.dropbox.com/s/fj90oh0b9yfnzsk/BadAndroidRefreshTest.zip?dl=0

Depending on the amount of memory on the device, you may have to rotate more times. On my Samsung Galaxy Tab 2, it takes about 8-9 rotations from landscape to portrait to cause the same out of memory stack:

11-11 15:59:41.070 E/MoreInfoHPW_ViewGroup(20747): Parent view is not a TextView
11-11 15:59:41.078 D/ProgressBar(20747): setProgress = 0
11-11 15:59:41.078 D/ProgressBar(20747): setProgress = 0, fromUser = false
11-11 15:59:41.078 D/ProgressBar(20747): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
11-11 15:59:41.570 D/ProgressBar(20747): setProgress = 0
11-11 15:59:41.570 D/ProgressBar(20747): setProgress = 0, fromUser = false
11-11 15:59:41.570 D/ProgressBar(20747): mProgress = 0mIndeterminate = true, mMin = 0, mMax = 100
11-11 15:59:41.578 I/Choreographer(20747): Skipped 42 frames! The application may be doing too much work on its main thread.
11-11 15:59:41.851 E/ViewRootImpl(20747): sendUserActionEvent() mView == null
11-11 15:59:41.921 I/dalvikvm-heap(20747): Clamp target GC heap from 49.070MB to 48.000MB
11-11 15:59:41.921 D/dalvikvm(20747): GC_FOR_ALLOC freed 90K, 4% free 46660K/48304K, paused 59ms, total 60ms
11-11 15:59:41.921 I/dalvikvm-heap(20747): Forcing collection of SoftReferences for 1980408-byte allocation
11-11 15:59:42.000 I/dalvikvm-heap(20747): Clamp target GC heap from 49.058MB to 48.000MB
11-11 15:59:42.000 D/dalvikvm(20747): GC_BEFORE_OOM freed 11K, 4% free 46649K/48304K, paused 74ms, total 74ms
11-11 15:59:42.000 E/dalvikvm-heap(20747): Out of memory on a 1980408-byte allocation.
11-11 15:59:42.000 I/dalvikvm(20747): "main" prio=5 tid=1 RUNNABLE
11-11 15:59:42.000 I/dalvikvm(20747): | group="main" sCount=0 dsCount=0 obj=0x41d2a9a0 self=0x41d1a1a8
11-11 15:59:42.000 I/dalvikvm(20747): | sysTid=20747 nice=0 sched=0/0 cgrp=apps handle=1075453148
11-11 15:59:42.000 I/dalvikvm(20747): | state=R schedstat=( 22075256289 4808746412 19411 ) utm=1887 stm=319 core=1
11-11 15:59:42.000 I/dalvikvm(20747): at android.graphics.Bitmap.nativeCreate(Native Method)
11-11 15:59:42.007 I/dalvikvm(20747): at android.graphics.Bitmap.createBitmap(Bitmap.java:718)
11-11 15:59:42.007 I/dalvikvm(20747): at android.graphics.Bitmap.createBitmap(Bitmap.java:695)
11-11 15:59:42.007 I/dalvikvm(20747): at android.graphics.Bitmap.createBitmap(Bitmap.java:662)
11-11 15:59:42.007 I/dalvikvm(20747): at xamarin.forms.platform.android.FrameRenderer_FrameDrawable.n_draw(Native Method)
11-11 15:59:42.007 I/dalvikvm(20747): at xamarin.forms.platform.android.FrameRenderer_FrameDrawable.draw(FrameRenderer_FrameDrawable.java:49)
11-11 15:59:42.015 I/dalvikvm(20747): at android.view.View.draw(View.java:14377)
11-11 15:59:42.015 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13327)
11-11 15:59:42.015 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13325)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14395)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13327)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13325)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14395)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13327)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14395)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13327)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13325)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13325)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13325)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.023 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13325)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13325)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.View.draw(View.java:14105)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.ViewGroup.drawChild(ViewGroup.java:3045)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2914)
11-11 15:59:42.031 I/dalvikvm(20747): at android.view.View.draw(View.java:14395)
11-11 15:59:42.039 I/dalvikvm(20747): at android.widget.FrameLayout.draw(FrameLayout.java:467)
11-11 15:59:42.039 I/dalvikvm(20747): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2536)
11-11 15:59:42.039 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13327)
11-11 15:59:42.039 I/dalvikvm(20747): at android.view.View.getDisplayList(View.java:13371)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1198)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2490)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2356)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2162)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1227)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4995)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.Choreographer.doFrame(Choreographer.java:561)
11-11 15:59:42.046 I/dalvikvm(20747): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
11-11 15:59:42.046 I/dalvikvm(20747): at android.os.Handler.handleCallback(Handler.java:725)
11-11 15:59:42.046 I/dalvikvm(20747): at android.os.Handler.dispatchMessage(Handler.java:92)
11-11 15:59:42.046 I/dalvikvm(20747): at android.os.Looper.loop(Looper.java:175)
11-11 15:59:42.046 I/dalvikvm(20747): at android.app.ActivityThread.main(ActivityThread.java:5279)
11-11 15:59:42.046 I/dalvikvm(20747): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 15:59:42.046 I/dalvikvm(20747): at java.lang.reflect.Method.invoke(Method.java:511)
11-11 15:59:42.046 I/dalvikvm(20747): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
11-11 15:59:42.046 I/dalvikvm(20747): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
11-11 15:59:42.046 I/dalvikvm(20747): at dalvik.system.NativeStart.main(Native Method)
11-11 15:59:42.046 I/dalvikvm(20747):
An unhandled exception occured.

I was also able to replicate this on a physical Samsung Galaxy Tab 2.
Comment 3 Jason Smith [MSFT] 2015-02-02 01:46:58 UTC
can you reproduce the issue without a custom renderer? If not the leak is in your renderer.
Comment 4 Wayne 2015-02-02 10:17:57 UTC
The sample code sent BadAndroidRefreshTest does not use a custom renderer.
Comment 5 Wayne 2015-02-02 11:02:23 UTC
Sample solution can be found at: https://www.radrite.com/uploads/BadAndroidRefreshTest.zip
Comment 6 Jason Smith [MSFT] 2015-02-04 05:14:01 UTC
Thank you, we have resolved the leak, it should be fixed in 1.3.4-pre1
Comment 7 Rajneesh Kumar 2015-02-11 06:02:03 UTC
I have checked this issue with Xamarin.Forms Version: 1.3.4.6328-pre2 and I am still able to reproduce this. To check this issue I have followed the instruction provided in comment 2. I have used a physical Samsung Galaxy Tab 2.

I observed that after following the reproducing steps getting following error/exception:
"Java.Lang.OutOfMemoryError: Exception of type 'Java.Lang.OutOfMemoryError' was thrown."

Hence reopening this issue.

===Supplement Info=====

Screencast: http://www.screencast.com/t/flP8cev5ww
Application Output: https://gist.github.com/Rajneesh360Logica/4087bc25d72f6cbf1f29
Build Out Put: https://gist.github.com/Rajneesh360Logica/5b6275e7e29c987b7ffb
Ide Logs: https://gist.github.com/Rajneesh360Logica/1d2cc43d92c4d0e621a6
android tools log: https://gist.github.com/Rajneesh360Logica/20b1f274cb189b3aefa9
Device Logs: https://gist.github.com/Rajneesh360Logica/f3a3f70752c27487369b

====Environment Info:====

Xamarin.Forms Version: 1.3.4.6328-pre2

=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.6.1.20 (Business Edition)
Hash: 3b3ef43
Branch: 
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.12.0.4 (Business Edition)

=== Build Information ===

Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 8 David Catteuw 2015-02-11 09:02:06 UTC
I can confirm this bug exists in XF 1.3.4-pre2.

Overview:
Buttons that have BackgroundColor set leak memory when rotating the Android device, ultimately crashing the app with an OutOfMemoryException.

Steps to quickly reproduce: (I will be including a zip with the solution)
- Create new Xamarin Forms PCL App project.
- Update to XF 1.3.4-pre2.
- Edit App constructor to this:
        public App()
        {
            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new Button
                {
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    BackgroundColor = Color.Red
                }
            };
        }
- Launch on hardware or virtual device.
- Rotate the device until the device runs out of memory and crashes.

Reproduced on:
- Visual Studio 2013
- Xamarin 1.3.4-pre2
- Xamarin Android 4.20.0.34
- Hardware Samsung Galaxy S5 Active & Nexus 4 emulator (both Android 4.4.2)

Debug log:
https://gist.github.com/Storm-BE/c90c6562f83d0dcb6ec3
Comment 9 David Catteuw 2015-02-11 09:05:17 UTC
Created attachment 9761 [details]
Small reproduction solution for memory leak using Button objects with a set BackgroundColor on Android
Comment 10 Wayne 2015-02-11 11:15:55 UTC
I can also confirm that the out of memory problem still exists in 1.3.4 pre2.  And doesn't seem to have anything to do with a button with a background color.  The sample solution I submitted (BadAndroidRefreshTest) did have 2 buttons, but if you remove these 2 buttons and redeploy, rotate the screen several times, you still get the out of memory bomb.
Comment 11 Jason Smith [MSFT] 2015-02-11 18:37:21 UTC
Thank you, remaining leak fixed and resolved in button renderer. I can no longer get crashing with it. If you are still having issues without buttons involved please file a new bug (so this bug doesn't because a catch all for all and any memory leaks).
Comment 12 Rajneesh Kumar 2015-02-13 05:28:18 UTC
As per comment 11, This issue has been fixed resolved in button render. If any one face this issue (Regarding Out of memory)  please refer the bug .

https://bugzilla.xamarin.com/show_bug.cgi?id=27007

Hence, I am closing this issue. 

Thanks