Results 1 to 3 of 3

Thread: Do new classes 'leak'?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    70

    Do new classes 'leak'?

    If I have something like this within a sub/function:
    Dim a as new myclass
    Does this leave a memory leak if I am constantly calling this function creating new instances of this class? Do I have to destroy it or something when I am done using it?

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Do new classes 'leak'?

    Read this article to learn a bit about how memory management in .NET works.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: Do new classes 'leak'?

    When the Sub/Function completes, the run-time engine knows that the variable you created is no longer going to be used. The Garbage Collector will eventually reclaim the memory pointed to by that local variable.

    No, a memory leak is not created in this case.

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