Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Memory used by my Application increases at each click of a mouse

Memory used by my Application increases at each click of a mouse

Scheduled Pinned Locked Moved Visual Basic
csharpperformancetutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashfaq Maniar
    wrote on last edited by
    #1

    When I run my VB.net WindowsApplication I can see that (in the Process tab of Windows Task manager) the mem usage keeps on increasing. Can someone tell me how to stop this or if we can retain the memory that was used up and no longer needed by the application. Ashfaq Maniar, Software Developer.

    Ashfaq Maniar, Software Developer.

    E 1 Reply Last reply
    0
    • A Ashfaq Maniar

      When I run my VB.net WindowsApplication I can see that (in the Process tab of Windows Task manager) the mem usage keeps on increasing. Can someone tell me how to stop this or if we can retain the memory that was used up and no longer needed by the application. Ashfaq Maniar, Software Developer.

      Ashfaq Maniar, Software Developer.

      E Offline
      E Offline
      Eduard Keilholz
      wrote on last edited by
      #2

      Erhm, there's this 'thing' called the Garbage Collector, this will clean up objects which are no longer in use. If thise 'collected' objects use loads of memory, that memory will be freed, and is available again. The garbage collector is very sophisticated and i'm pretty much sure it works fine for most applications. However, as programmer, you need to 'tell' the garbage collector which objects aren't used anymore. This way you will 'help' the garbage collector finding objects to free from memory. All objects derived from the IDisposable interface, have this method called Dispose(). Dispose() will clean up all resources the object uses. If you're done using an object, call the Dispose() method so the garbage collector can do it's work. In C# the using statement helps you to not forget to call the dispose method. The example below instantiates a new object, but because i'm doing this with the using statement, the object will automatically dispose at the last bracket using (ObjectType myObject = new ObjectType()) { myObject.DoSomething(); } This code is by the way the same as : ObjectType myObject = new ObjectType(); myObject.DoSomething(); myObject.Dispose(); You also need to find out which of your own classes are suitable to implement the IDisposable interface to they can also dispose themselves. The garbage collector runs pretty much automaticly and you shouldn't interfere, however if you really feel like freeing memory is useful at a certain point, you can call the garbage collectors Collect() method : GC.Collect(); The collect however is pretty time-consuming and neat programmers don't need to use the Collect(). There may be exceptions to that however...

      .: I love it when a plan comes together :. http://www.zonderpunt.nl

      A 1 Reply Last reply
      0
      • E Eduard Keilholz

        Erhm, there's this 'thing' called the Garbage Collector, this will clean up objects which are no longer in use. If thise 'collected' objects use loads of memory, that memory will be freed, and is available again. The garbage collector is very sophisticated and i'm pretty much sure it works fine for most applications. However, as programmer, you need to 'tell' the garbage collector which objects aren't used anymore. This way you will 'help' the garbage collector finding objects to free from memory. All objects derived from the IDisposable interface, have this method called Dispose(). Dispose() will clean up all resources the object uses. If you're done using an object, call the Dispose() method so the garbage collector can do it's work. In C# the using statement helps you to not forget to call the dispose method. The example below instantiates a new object, but because i'm doing this with the using statement, the object will automatically dispose at the last bracket using (ObjectType myObject = new ObjectType()) { myObject.DoSomething(); } This code is by the way the same as : ObjectType myObject = new ObjectType(); myObject.DoSomething(); myObject.Dispose(); You also need to find out which of your own classes are suitable to implement the IDisposable interface to they can also dispose themselves. The garbage collector runs pretty much automaticly and you shouldn't interfere, however if you really feel like freeing memory is useful at a certain point, you can call the garbage collectors Collect() method : GC.Collect(); The collect however is pretty time-consuming and neat programmers don't need to use the Collect(). There may be exceptions to that however...

        .: I love it when a plan comes together :. http://www.zonderpunt.nl

        A Offline
        A Offline
        Ashfaq Maniar
        wrote on last edited by
        #3

        I am using VB.net When ever a class is not usable i type class1 = nothing But the main problem is .... when a form is open and when you click anywhere on the form...the consumed memory still goes up and comes down only when the user closes the application.

        Ashfaq Maniar, Software Developer.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups