[Mono-osx] MonoMac retain/release
gnorton at novell.com
Tue Apr 20 13:54:50 EDT 2010
On 2010-04-20, at 1:45 PM, Duane Wandless wrote:
> That sounds like the retain/release is then being automatically handled. Once the object is referenced inside C# the retain occurs. Then when the C# object is GCed the release should occur. Is that correct? Which if it is then all I should have to do is set the C# variable to null or call Dispose and I have the same basic functionality I listed.
This is correct (the Disposer is what cleans up as well so if you want to be deterministic with the native object graph you call Dispose).
> It would probably also be worthwhile making retainCount public. As this is a useful debugging technique for memory leaks.
Considering how much we monkey with this (multiple managed references are in 1 slot, additionally with nsautorelease pool) I'm not sure I want this in the public api. You can get at it yourself trivially:
Messaging.uint_objc_msgSend (objc.Handle, Selector.GetHandle ("retainCount"));
> I have yet to use MonoMac so I'm still guessing a bit on how the interaction with native obj-c code will work. I just want to ensure I'm not loosing obj-c functionality. Having control of the retain cycle is an important 'feature' of obj-c.
Its not a 'feature' its a requirement, and we aim to remove that requirement by letting people use the GC.
> On Tue, Apr 20, 2010 at 1:37 PM, Geoff Norton <gnorton at novell.com> wrote:
> Whenever we bubble a proxy object, it takes a reference to the underlying native object, as such in the circumstance you described the object could not "go away"
> On 2010-04-20, at 1:24 PM, Duane Wandless wrote:
> > I noticed that retain/release/autorelease our internal methods. I'm not fan of doing memory management as that takes away time from solving business needs. Memory management is required with obj-c. And I believe these should be public.
> > There are times when an object is passed as an argument into my C# code that must be retained while the C# code manipulates the object (typically a UI object)... then release that object when done. The most common usage is the UI is a delegate for the async C# method. At times the UI object will go away while the C# code is running its async task. The retain of course prevents sending a selector to a deallocated object. And there are times when the UI delegate selector is not invoked so I must be able to release the UI object from the C# code.
> > I think one of the fundamental design patterns of MonoTouch and now MonoMac is that all the code will be written in C#. I do think this assumption is limiting. Giving the C# code full access to the obj-c objects allows for truly the best of both worlds. The advantages of the C# language can be leveraged.. but without limiting the functionality of the various NS classes within C#.
> > Again my usage is a native obj-c app for the UI with the business logic in C#. There are advantages to fully developing within C# MonoMac . I just want to push the design so that is not required.
> > Duane
> > _______________________________________________
> > Mono-osx mailing list
> > Mono-osx at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-osx
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-osx