Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms never going out of scope

Status
Not open for further replies.

fosterm

Programmer
Feb 3, 2003
8
GB
Hi all

I'm tearing my hair out trying to find out why my forms won't go out of scope..

For example

My code is

Dim objform as frmProductEdit

Set objform = new frmproductEdit

ObjForm.showdialog

'Then - when the form is closed by user

objform = nothing

I'm using the .net memory profiler and the number of live instances of a form does not decrease when i close the form

Therefore pretty soon, my app starts to struggle for memory as the product form is opened a number of times

I've tried using objform.dispose before setting it nothing and calling garbage collection but nothing seems to kill off the form instance

Any ideas on what i'm doing wrong. I'm pretty new to .net from vb6

Cheers

MArk



 
.Net uses a garbage collector that will release memory as it is needed. So if you .dispose your form and set it to nothing, it will still be in memory until the garbage collector decides that it needs more memory.

I think Chiph may have posted a way to force the GC to collect everything, but I can't recall what the solution was.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks for your help

The trouble is I can see clearly on the memory profiler where garbage collections have taken place but the form stays a live instance

I've tried doing forced collections with gc.collect but the damm things won't die :)
 
I do have some com components on other forms elsewhere in the project but not on the one I'm testing at the moment

There's a few standard windows forms controls, Janus explorer bar for .net and a custom textbox control i made myself

I'm wondering if the custom textbox could be the problem. Basically it was just a control I made with a standard textbox on it with a few extra properties added that were relevant to my app

Is it possible that the textbox inside each instance of my custom control is making the form stay alive ?

As you can probably tell, all this gc stuff is pretty new to me !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top