CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Memery!!

  1. #1
    Join Date
    Feb 2001
    Posts
    27

    Memery!!

    Can anybody suggest a good tool to find out what is responsable for a process that hangs around after application termination - my program does obviously not close eveything properly but i cannot find the source of the problem, any suggestions of tools would be greatful..


  2. #2
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: Memery!!

    Check if you're using Unload instead of End to end your program. Consider the following:

    In Form1 (main form):

    sub ShowForm2()
    Form2.Show()
    end sub

    sub CloseForm1()
    Unload me
    end sub




    In Form2:

    sub cmdClose_Click()
    me.Hide
    end sub




    So since Form2 is actually still in the memory (hidden object), you application does not really exit. But if you were to replace "Unload me" with "End", then you can assured that you application will be forced to exit.

    Of course there are probably many other rootcauses but this is the one that I encountered when I first playing with VB.

    -Cool Bizs

    Good Luck,
    -Cool Bizs

  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Memery!!

    A good way to ensure that all processes are terminated is to unload all forms in the Form_Unload event of the terminating form like so.

    private Sub Form_Unload(Cancel as Integer)
    Dim f as Form
    for Each f In Forms
    If f.Name <> me.Name then
    Debug.print f.Name
    Unload f
    End If
    next f

    End Sub



    THis will give each form a chance to execute its individual Form_Unload event.

    John G

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured