Re: [Mono-gc-list] Mono memory problems!

David Wolinsky <[email protected]> Wed, 18 Jul 2007 16:30:54 -0400
Newsgroups gmane.comp.gnome.mono.devel,gmane.comp.gnome.mono.garbage-collection
Message-ID <[email protected]>
In fact, I was able to fix the problem.

For some reason in WaitHandle.cs, the line...
safe_wait_handle =3D new SafeWaitHandle (value, false);
should be...
safe_wait_handle =3D 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 =3D=3D 0, but calling DangerousGetHandle throws an exception if =

refcount =3D=3D 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=E4rber wrote:
>
> Am 18.07.2007 um 19:54 schrieb David Wolinsky:
>
>> That case leaks as well.
>>
>> Regards,
>> David
>>
>> Miguel de Icaza wrote:
>>>>         re =3D 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 =3D AutoResetEvent (false)) {   =

>>>         ...
>
> Doesn't Close() call Dispose()? At least for the Stream classes it =

> should.
>
> Andreas
>