My VB.NET application is having a memory problem. It consist in a menu
form (mform) which calls other forms (oform). Actually, the mform
doesn't call the oform directly, it creates a new thread where the
oform is created and called. When the oform is closed its thread is
set to nothing, but the oform's memory remains.
I'm using MemProfiler in order to know which objects are allocated in
memory. I've also used perfmon invoking the GC and I can see that the
memory keeps increasing. I thought that when the thread, which has
created the oform, is released the oform would be released too. But my
app don't behave like that.
Is it posible to create a thread that when is finished disposes all
its objects? What could be happening to my app?
Thanks in advance.
>Is it posible to create a thread that when is finished disposes all
>its objects?
Not automatically, no. There's no such connection between an object
and the thread it was created on.
Winforms keeps its form objects alive as long as the window is open.
Have you closed the window?
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
javiers - 24 May 2007 17:49 GMT
Yes, I've closed the windows and set it to nothing. I can see also
that the dispose method is correctly called.
On 24 mayo, 13:38, Mattias Sj?gren <mattias.dont.want.s...@mvps.org>
wrote:
> >Is it posible to create a thread that when is finished disposes all
> >its objects?
[quoted text clipped - 10 lines]
> Mattias Sj?gren [C# MVP] mattias @ mvps.orghttp://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
> Please reply only to the newsgroup.
> form (mform) which calls other forms (oform). Actually, the mform
> doesn't call the oform directly,
Right. It can't.
>it creates a new thread where the
> oform is created and called.
I don't understand what that means how this is possible. You'll need to
explain this some more.
>When the oform is closed its thread is
> set to nothing, but the oform's memory remains.
It's got a root. That's the long and short of it. First let's deal with your
design, fixing the leak should be easy after the design is explained.

Signature
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
https://www.microsoft.com/MSPress/books/10933.aspx
OWC Black Book www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
> My VB.NET application is having a memory problem. It consist in a menu
> form (mform) which calls other forms (oform). Actually, the mform
[quoted text clipped - 11 lines]
>
> Thanks in advance.