Bug 27431 - Managed objects in the CALayer hierarchy are not held in memory
Summary: Managed objects in the CALayer hierarchy are not held in memory
Status: RESOLVED DUPLICATE of bug 26532
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: XI 8.6.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 8.10
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-02-25 15:57 UTC by jesse.attas
Modified: 2015-03-03 14:21 UTC (History)
3 users (show)

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


Attachments
Simple app that reproduces the bug (12.29 KB, application/zip)
2015-02-25 15:57 UTC, jesse.attas
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:
RESOLVED DUPLICATE of bug 26532

Description jesse.attas 2015-02-25 15:57:26 UTC
Created attachment 10034 [details]
Simple app that reproduces the bug

I have a custom class that derives from CALayer. If I add an instance to the layer hierarchy and then force a GC, the managed instance is disposed. If I try to access it later, it has to go through the IntPtr constructor and it loses all of its property values.

This only seems to be a problem if my custom CALayer is a grandchild of CALayer (or great grandchild). If it's a child of CALayer it is correctly held in memory.

In the attached test app, perform the following steps to reproduce:
1. Run the app. You see a view with a child layer (red box) and two system buttons.
2. Press the "Access" button. This traverses the layer hierarchy to find the custom layer and prints some of its properties.
3. Press the "Garbage Collect" button. This forces a GC.
4. Press the "Access" button again. Notice the message saying the layer's IntPtr constructor is called. Notice that the layer's properties are back to their default values.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-02-26 04:53:21 UTC
This is probably a dup of #26532.
Comment 2 Parmendra Kumar 2015-02-26 06:56:04 UTC
I have checked this issue and I am getting same behavior mentioned in the bug description.

Screencast: http://www.screencast.com/t/UvXuQF7q

AppOutput Log: https://gist.github.com/Parmendrak/8a82caec1da2b1b416de
IDE Log:https://gist.github.com/Parmendrak/c5784f47d7b556178138

Environment info:
=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Runtime:
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.1.26 (Business Edition)
Hash: 98ee412
Branch: 
Build date: 2015-02-11 04:37:05-0500

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/360_macmini/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.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

=== 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.4
Darwin ShrutiMac.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-03-03 14:21:01 UTC
This is a dup of bug #26532.

With maccore/master the test app prints this (repeatedly) in the Application Output when clicking the buttons:

> MyInt is 42
> MyString is hello

The fix will be shipped in Xamarin.iOS 8.10.

*** This bug has been marked as a duplicate of bug 26532 ***