What's memory leak?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Van

    What's memory leak?

    I think I know what it is-- objects not being set to nothing
    when the program is finished with them

    How can I tell if I have it?

    How can I code to avoid it?

    Thanks



  • Dikkie Dik

    #2
    Re: What's memory leak?

    Tony Van wrote:[color=blue]
    > I think I know what it is-- objects not being set to nothing
    > when the program is finished with them[/color]

    That's one. If you have circular references (two objects pointing to
    each other, but your program doesn't point to either of them anymore),
    the objects are not automatically cleared. This can result in a
    "hanging" application, because VB is apparently waiting for either of
    them to be set to nothing.

    If you are working with API calls, a memory leak can also be a memory
    structure generated by the API call that is not properly "handed back"
    to the operating system.
    [color=blue]
    >
    > How can I tell if I have it?[/color]

    Especially the last one: you probably can't.[color=blue]
    >
    > How can I code to avoid it?[/color]

    Avoid circular references, or implement some sort of Dispose method. Be
    aware that if a form has an object variable that contains an object
    pointing to controls on that form, VB regards it as a circular reference.
    You can also use close/unload/terminate events to trigger disposal code.

    Best regards

    Comment

    • Tony Van

      #3
      Re: What's memory leak?

      Thanks for a clear explanation Dik.

      Need to look thru my code more carefully.



      Comment

      Working...