locked
Performance monitoring. RRS feed

  • Question

  • Hi,

    I get an application and I don't have the source code but I would like to know if there is any leack of memory in this application.
    So I would like to code an application running in background which will log the memory and the processor state .
    Do you know if it's possible to get some information about the memory used in the device, the processor used, and more particulary by a specific application.

    Thanks a lot,

    Friday, June 2, 2006 6:06 PM

Answers

  • Hi,
    I found my answer !!

    This is the code :

    • First :
            [StructLayout(LayoutKind.Sequential)]
            public struct MEMORYSTATUS
            {
                public uint dwLength;
                public uint dwMemoryLoad;
                public uint dwTotalPhys;
                public uint dwAvailPhys;
                public uint dwTotalPageFile;
                public uint dwAvailPageFile;
                public uint dwTotalVirtual;
                public uint dwAvailVirtual;
            }

    [DllImport("coredll")]
    static extern void GlobalMemoryStatus(ref MEMORYSTATUS buf);

    • and then :
    MEMORYSTATUS memSt = new MEMORYSTATUS();
    GlobalMemoryStatus(ref memSt);

    Available Page File (kb):                        (memSt.dwAvailPageFile / 1024)
    Available Physical Memory (kb),             (memSt.dwAvailPhys / 1024)
    Available Virtual Memory (kb),               (memSt.dwAvailVirtual / 1024)
    Size of structur :                                      memSt.dwLength
    Memory In Use :                                    memSt.dwMemoryLoad.
    Total Page Size (kb):                             (memSt.dwTotalPageFile / 1024)
    Total Physical Memory (kb),                  (memSt.dwTotalPhys / 1024)
    Total Virtual Memory (kb),                    (memSt.dwTotalVirtual / 1024)
    Tuesday, June 6, 2006 9:08 PM

All replies

  • Hi,
    I found my answer !!

    This is the code :

    • First :
            [StructLayout(LayoutKind.Sequential)]
            public struct MEMORYSTATUS
            {
                public uint dwLength;
                public uint dwMemoryLoad;
                public uint dwTotalPhys;
                public uint dwAvailPhys;
                public uint dwTotalPageFile;
                public uint dwAvailPageFile;
                public uint dwTotalVirtual;
                public uint dwAvailVirtual;
            }

    [DllImport("coredll")]
    static extern void GlobalMemoryStatus(ref MEMORYSTATUS buf);

    • and then :
    MEMORYSTATUS memSt = new MEMORYSTATUS();
    GlobalMemoryStatus(ref memSt);

    Available Page File (kb):                        (memSt.dwAvailPageFile / 1024)
    Available Physical Memory (kb),             (memSt.dwAvailPhys / 1024)
    Available Virtual Memory (kb),               (memSt.dwAvailVirtual / 1024)
    Size of structur :                                      memSt.dwLength
    Memory In Use :                                    memSt.dwMemoryLoad.
    Total Page Size (kb):                             (memSt.dwTotalPageFile / 1024)
    Total Physical Memory (kb),                  (memSt.dwTotalPhys / 1024)
    Total Virtual Memory (kb),                    (memSt.dwTotalVirtual / 1024)
    Tuesday, June 6, 2006 9:08 PM
  • hi,

    your post was very helpful, thanks alot.

    this is about memory, but what about processor? do you know how to get the processor usage percentage like in windows xp task manager?

    thanks

    Friday, September 1, 2006 10:34 PM
  • There is already some application to get a little "task manager" but I can't remember the name...

    I thing there is one published by microsoft.

    Saturday, September 16, 2006 6:41 PM