RE: why doesn't GC release the form's memory?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



How do you know that the GC does not remove the form from memory? The GC does
a collection only when there is some kind of memory pressure. If not,
collections run at a lower frequency. The form will be collected when the
next collection runs.

Also if an object has a dispose method, it is always preferable that you
call it so that unmanaged resources are cleaned up fast.

--
Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com


"**Developer**" wrote:

> Private Sub KeyboardShortcuts()
>
> Dim ff As New FormHelp
>
> ff.Show()
>
> End Sub
>
> End Class
>
>
>
> Seems to me that ff is on the stack (?maybe not) and references the instance
> of FormHelp. After the sub exits ff nolonger exists and nothing references
> the form so why doesn't GC release the form's memory?
>
> Even if ff is not on the stack after the sub exits ff should be available
> for GC. No?
>
> Thank
>
>
>
.



Relevant Pages

  • Re: Postscript problems
    ... there are two kinds of objects on the operand stack. ... stack but in a memory called the VM. ... If you use "dup" on a composite object, then you duplicate the reference ... storage area (and you manipulate references to that other shared value). ...
    (comp.lang.postscript)
  • Re: memory loss reassigning image to Button
    ... so it's link to the image object should disappear when the sub exits. ... to the old image would vanish, and the memory would be reclaimed. ... I have no particular skills in debugging memory leaks. ...
    (comp.lang.perl.tk)
  • Re: Value vs Reference Types
    ... the references are just that, references to the managed objects, which do ... not reside on the stack. ... > memory address in the heap ... , but rather, just an object on the heap. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: why doesnt GC release the forms memory?
    ... > How do you know that the GC does not remove the form from memory? ... >> Seems to me that ff is on the stack and references the ... After the sub exits ff nolonger exists and nothing ... >> Even if ff is not on the stack after the sub exits ff should be available ...
    (microsoft.public.dotnet.languages.vb)
  • Re: If Macs have no spyware....
    ... >had made a complete code review of its operating system and removed all ... and writing new data into those memory locations would ... >but when the data exists on the stack, it can cause very large problems. ... >location that needs to be written in place of the correct execution ...
    (comp.sys.mac.advocacy)