CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 1999
    Location
    Montreal, Quebec, Canada
    Posts
    192

    Memory of the process

    I have a memory leak in my application and I want to find it of course..

    What is the way to track the memory of the current process in VB? I mean, I do have API functions to get the amount of free memory, but that implies other applications and services doesn't eat memory when I'm testing...

    Thank you!


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Memory of the process

    Before running the program start Resource meter and check how much memory your app uses. You will find recource meter in Program/Accescories/System Tools.

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Jul 1999
    Location
    Montreal, Quebec, Canada
    Posts
    192

    Re: Memory of the process

    Actually, this wouldn't have been useful.

    I found everything I needed with the GetProcessMemory API function...

    For readers:


    Type PROCESS_MEMORY_COUNTERS
    cb as Long
    PageFaultCount as Long
    PeakWorkingSetSize as Long
    WorkingSetSize as Long
    QuotaPeakPagedPoolUsage as Long
    QuotaPagedPoolUsage as Long
    QuotaPeakNonPagedPoolUsage as Long
    QuotaNonPagedPoolUsage as Long
    PagefileUsage as Long
    PeakPagefileUsage as Long
    End Type

    private Declare Function GetCurrentProcess Lib "kernel32" () as Long
    private Declare Function GetProcessMemoryInfo Lib "psapi.dll" (byval lHandle as Long, lpStructure as PROCESS_MEMORY_COUNTERS, byval lSize as Long) as Integer




    and in your function:


    Dim lngReturn as Long
    Dim typMem as PROCESS_MEMORY_COUNTERS

    lngReturn = GetProcessMemoryInfo(GetCurrentProcess(), typMem, len(typMem))
    Debug.print CStr(typMem.WorkingSetSize)




    This works like a charm...! I found the ADO connection was leaking memory for some reason... even if I closed it and set it to nothing!



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

Featured