473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.

Nov 12 '07 #1
3 3590
em*************@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
Nov 12 '07 #2
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]
- mv*@spam.guard.caspershouse.com

"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:47***********************@news.sunsite.dk...
em*************@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

Nov 12 '07 #3
Additionally, java provides tools which will allow monitoring of the
JVM:

http://java.sun.com/performance/jvmstat/
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:47***********************@news.sunsite.dk...
em*************@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

Nov 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ANt | last post by:
Hi, we have some major GC issues at present with a system we're trying to put live. It's a live calculation engine that's distributed across about 30 Java server processes. A set of processes...
17
by: Jonas Rundberg | last post by:
Hi I just started with c++ and I'm a little bit confused where stuff go... Assume we have a class: class test { private: int arr; };
10
by: Shuo Xiang | last post by:
Greetings: I know that variables declared on a stack definitely does not reside in heap space so there is only a very limited amount of stuff that you can store in the stack of a function. But...
4
by: rd | last post by:
Hi i'm uncertain about foll. things. Thanks in advance for any help to get me out of this.. >>Each process, with their own stack, will they have their own heap or is it global one(common for...
9
by: shine | last post by:
what is the difference between a heap and a stack?
3
by: Aravindakumar Venugopalan | last post by:
Hi , A Windows form application which interacting with the unmanaged C++ codes . In unmanaged c++ code we allocate around 130MB on the heap for annalysing high resolution images . Earlier...
16
by: JCauble | last post by:
We have a large Asp.net application that is currently crashing our production servers. What we are seeing is the aspnet_wp eat up a bunch of memory and then stop unexpectedly. Does not recycle. ...
11
by: ganesh.kundapur | last post by:
Hi, Is there any way to get the total heap size allocated to a process in c on linux platform. Regards, Ganesh
5
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.