[Mono-gc-list] [Mono-dev] Mono memory problems!

Jonathan Gagnon jonathan.gagnon at croesus.com
Tue Jul 24 08:58:49 EDT 2007


I'm pretty sure that this will fix bug #81727 that I filed a few months ago,
although I don't have time to test it for the moment.

Jonathan Gagnon 

-----Message d'origine-----
De : mono-devel-list-bounces at lists.ximian.com
[mailto:mono-devel-list-bounces at lists.ximian.com] De la part de Miguel de
Icaza
Envoyé : Wednesday, July 18, 2007 8:17 PM
À : David Wolinsky
Cc : Andreas Färber; Peer-to-peer networking group discussions;
mono-gc-list at lists.ximian.com; mono-devel
Objet : Re: [Mono-dev] [Mono-gc-list] Mono memory problems!

Hello folks,

    Thanks for tracking this problem down.

    Thanks for pointing out the comment in the source code;  I went and
re-read the documentation and I clearly did not understand it the first time
over, because the leak was documented to happen only in the .NET 1.0 and 1.1
scenarios, not on the 2.0 scenario.

    So the fix that takes ownership is correct.    I tidied up the patch
a little bit as well.   The fix is now on svn, thanks again for tracking
this down.

> In fact, I was able to fix the problem.
> 
> For some reason in WaitHandle.cs, the line...
> safe_wait_handle = new SafeWaitHandle (value, false); should be...
> safe_wait_handle = new SafeWaitHandle (value, true); (at least it 
> makes sense according to other docs I read)...
> 
> second... in SafeWaitHandle.cs, the line ...
>             NativeEventCalls.CloseEvent_internal 
> (DangerousGetHandle()); should be...
>             NativeEventCalls.CloseEvent_internal (handle);
> 
> The second one is kind of silly because Release gets called only after 
> refcount == 0, but calling DangerousGetHandle throws an exception if 
> refcount == 0.
> 
> I think there is still a problem of the array of wapi handles not 
> being shrunk down, but that complexity is beyond me.
> 
> Regards,
> David
> 
> Andreas Färber wrote:
> >
> > Am 18.07.2007 um 19:54 schrieb David Wolinsky:
> >
> >> That case leaks as well.
> >>
> >> Regards,
> >> David
> >>
> >> Miguel de Icaza wrote:
> >>>>         re = new AutoResetEvent(false);
> >>>>         re.Close();
> >>>
> >>> That depends on the finalizer to run to release memory from the 
> >>> unmanaged side, since AutoResetEvent implements IDisposable you 
> >>> should use it like this:
> >>>
> >>>     using (re = AutoResetEvent (false)) {   
> >>>         ...
> >
> > Doesn't Close() call Dispose()? At least for the Stream classes it 
> > should.
> >
> > Andreas
> >
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-gc-list mailing list