Memory Usange In VB.NET

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

    #1

    Memory Usange In VB.NET

    When I run this centence, The memory raise 4Mb in memory:
    If Process.GetProc essesByName("AB C,EXE").Length 1 Then

    And the routine is end, the memory doesn't drop,
    Actually, How Can I free up my memory in a VB.NET application?

    GC.collect() seems not so work.

  • Michel Posseth [MCP]

    #2
    RE: Memory Usange In VB.NET

    My counter question to you is Why ?


    As the architecture of a .Net app is to reserve memory

    I.O.W.

    A .Net Program reserves memory during execution it doesn`t mean that it is
    actually using this memory space . advantage of this aproach is a higher
    execution speed as memory does not have to be claimed and released on every
    memory intensive call .

    read this for detailed info :

    http://msdn.microsoft.com/library/de...tperftechs.asp


    if you really need to free up the memory , thus solving this "cosmetic"
    problem

    you can do this :

    Private Declare Function SetProcessWorki ngSetSize Lib "kernel32.d ll" ( _
    ByVal process As IntPtr, _
    ByVal minimumWorkingS etSize As Integer, _
    ByVal maximumWorkingS etSize As Integer) As Integer

    GC.Collect()
    GC.WaitForPendi ngFinalizers()
    SetProcessWorki ngSetSize(Proce ss.GetCurrentPr ocess().Handle, -1, -1)


    regards

    Michel Posseth [MCP]




    "Cylix" wrote:
    When I run this centence, The memory raise 4Mb in memory:
    If Process.GetProc essesByName("AB C,EXE").Length 1 Then
    >
    And the routine is end, the memory doesn't drop,
    Actually, How Can I free up my memory in a VB.NET application?
    >
    GC.collect() seems not so work.
    >
    >

    Comment

    • Cylix

      #3
      Re: Memory Usange In VB.NET

      But I just use that line once and never use it any more.
      So I don't want it to keep any cache ...

      Comment

      • Michel Posseth [MCP]

        #4
        Re: Memory Usange In VB.NET

        No it isn`t about caching values

        The framework determines the potential memory usage of your program and
        reserves the memory ,

        If you don`t use it fine ,,, but if you might use it this would speed op the
        overall perfomance of your application .


        if the system is running low on memory the GC could kick in and give the
        memory back to the system ,,, however with modern computers this is not
        lickely to happen so often .

        as i said i once had a customer who demanded a low mem usage in the
        taskmanager so i used the trick i showed in my previous post ,,, however this
        is more cosmetic as a reall usage strategy as it hurts the performance of
        your application .


        regards

        Michel Posseth [MCP]


        "Cylix" wrote:
        But I just use that line once and never use it any more.
        So I don't want it to keep any cache ...
        >
        >

        Comment

        • Cylix

          #5
          Re: Memory Usange In VB.NET

          Dear Michel,

          I would like to know more about this.
          I have already tried your code and it really make the memory shown on
          task manager.
          May I know what memory is release under your code?

          And how it hunrt the application performance?

          Actually, In my office, most of computer is P4 2GHz with 512MB Ram,
          but some of old machines are just P3 800MHz, 256MB Ram,
          They need to open a number of MS Word and MS OUTLOOK Items.

          So, The memory is really limited.

          Comment

          • Jovo Mirkovic

            #6
            RE: Memory Usange In VB.NET



            It's working... but it only increase Memory, Virtual Memory is still
            growing..:(

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

            Comment

            Working...