[Mono-dev] [Mono-gc-list] Mono memory problems!
Miguel de Icaza
miguel at novell.com
Wed Jul 18 20:16:32 EDT 2007
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
More information about the Mono-devel-list
mailing list