Memory management

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dagoberto Aceves

    #1

    Memory management

    I have a program that is working as the front end to SQL Server. But I
    noticed that as the program runs, the momery use just keeps going up. At
    first, I thought it was that I was running it through .NET, but then
    that reasoning didn't make much sense.

    I tried adding a button to dispose of everything, and close all
    connections, but the memory use didn't really change. Right now im
    blaming the way i went about opening new forms.

    //
    form.show
    me.close
    //

    This is my first time with VB.NET and i think i placed too much faith on
    the GC. Any help, advice, please any one..

    *** Sent via Developersdex http://www.developersdex.com ***
  • ng

    #2
    Re: Memory management

    I strongly recommend using a form variable, such as:
    Dim frmM as frmMain

    frmM = new frmMain
    frmM.show()

    Then when frmM is unloaded, all the code associated with it is unloaded
    also. If you just load a form by its true name, only the visual portion
    is unloaded, but all the code is still in memory. Eventually the .Net
    garbage collector is supposed to dispense with those straggling code
    blocks, but I don't have that much confidence in it. And who knows when
    it will get around to it. If you are opening and closing forms rapidly,
    you can easily overwhelm the poor thing.

    Tom


    Dagoberto Aceves wrote:
    [color=blue]
    >I have a program that is working as the front end to SQL Server. But I
    >noticed that as the program runs, the momery use just keeps going up. At
    >first, I thought it was that I was running it through .NET, but then
    >that reasoning didn't make much sense.
    >
    >I tried adding a button to dispose of everything, and close all
    >connections, but the memory use didn't really change. Right now im
    >blaming the way i went about opening new forms.
    >
    >//
    >form.show
    >me.close
    >//
    >
    >This is my first time with VB.NET and i think i placed too much faith on
    >the GC. Any help, advice, please any one..
    >
    >*** Sent via Developersdex http://www.developersdex.com ***
    >
    >[/color]

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Memory management

      Dagoberto,

      If you go to the newsgroup Microsoft.publi c.dotnet.genera l, than you will
      see that that newsgroup is loaded with your question.

      The problem is the TaskManager which most people are using to see the
      memory. That function is not reliable.

      The GC has to start working if there is memory needed in a kind of iddle
      time. In fact it is working much more.

      //
      form.show
      me.close
      //
      This procedure shows an existing form object, me close tells that the object
      that is instanced with new as the running object has to be closed. It is for
      sure not the form that you have showed.

      I hope this gives some ideas

      Cor


      Comment

      Working...