Heap Memory of a Windows Process - CSharp

This is a discussion on Heap Memory of a Windows Process - CSharp ; how can i get heap memory of a windows process with C#? For example, I would like to see the value of the heap memory allocated for my "java.exe" process. thanks in advance....

+ Reply to Thread
Results 1 to 4 of 4

Heap Memory of a Windows Process

  1. Default Heap Memory of a Windows Process

    how can i get heap memory of a windows process with C#? For example, I
    would like to see the value of the heap memory allocated for my
    "java.exe" process.

    thanks in advance.


  2. Default Re: Heap Memory of a Windows Process

    emer.kurbegovic@gmail.com wrote:
    > how can i get heap memory of a windows process with C#? For example, I
    > would like to see the value of the heap memory allocated for my
    > "java.exe" process.


    It is probably impossible to get a true mesaurement if Java heap,
    becaus ethat is "java internals", but some quick experimentation
    showed that:

    Process[] p = Process.GetProcessesByName("java");
    Console.WriteLine(p[0].WorkingSet64);

    produced a decent approximation on my system.

    I will not guarantee that it will on your system, but you
    could try it.

    Arne

  3. Default Re: Heap Memory of a Windows Process

    I dobut that this would always be a good approximation. You are getting
    the working set, which is by no means an accurate representation of heap
    size.

    If you want to get the statistics for the heap, you have to get the
    runtime from within the app through a call to the static getRuntime method
    on the Runtime class, and then access the various methods which detail the
    runtime at that particular point (totalMemory, maxMemory, freeMemory
    methods).

    Those values would have to be pushed out of the process (in a manner
    that can be read by your process). A file is the first thing that comes to
    mind.

    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard.caspershouse.com

    "Arne Vajh°j" <arne@vajhoej.dk> wrote in message
    news:4738d0ce$0$90266$14726298@news.sunsite.dk...
    > emer.kurbegovic@gmail.com wrote:
    >> how can i get heap memory of a windows process with C#? For example, I
    >> would like to see the value of the heap memory allocated for my
    >> "java.exe" process.

    >
    > It is probably impossible to get a true mesaurement if Java heap,
    > becaus ethat is "java internals", but some quick experimentation
    > showed that:
    >
    > Process[] p = Process.GetProcessesByName("java");
    > Console.WriteLine(p[0].WorkingSet64);
    >
    > produced a decent approximation on my system.
    >
    > I will not guarantee that it will on your system, but you
    > could try it.
    >
    > Arne




  4. Default Re: Heap Memory of a Windows Process

    Additionally, java provides tools which will allow monitoring of the
    JVM:

    http://java.sun.com/performance/jvmstat/


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard.caspershouse.com

    "Arne Vajh°j" <arne@vajhoej.dk> wrote in message
    news:4738d0ce$0$90266$14726298@news.sunsite.dk...
    > emer.kurbegovic@gmail.com wrote:
    >> how can i get heap memory of a windows process with C#? For example, I
    >> would like to see the value of the heap memory allocated for my
    >> "java.exe" process.

    >
    > It is probably impossible to get a true mesaurement if Java heap,
    > becaus ethat is "java internals", but some quick experimentation
    > showed that:
    >
    > Process[] p = Process.GetProcessesByName("java");
    > Console.WriteLine(p[0].WorkingSet64);
    >
    > produced a decent approximation on my system.
    >
    > I will not guarantee that it will on your system, but you
    > could try it.
    >
    > Arne




+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 09-16-2007, 08:44 PM
  2. Heap and Memory Footprint
    By Application Development in forum Java
    Replies: 6
    Last Post: 06-11-2007, 04:05 PM
  3. Replies: 1
    Last Post: 04-17-2006, 04:11 PM
  4. Memory leak because of fragmented Large Object Heap?
    By Application Development in forum DOTNET
    Replies: 6
    Last Post: 03-02-2005, 06:09 PM
  5. Out of Memory (heap overflow)
    By Application Development in forum Clarion
    Replies: 3
    Last Post: 12-03-2004, 12:26 PM