1833759 Members
2424 Online
110063 Solutions
New Discussion

Re: C heap size

 
Praveen Bezawada
Respected Contributor

C heap size

Hi
If a Java program includes native methods ( in C ), how can we find the memory being used by the native part of the program.
And also how can we find the memory being used by the JVM itself. Does the glance metric
PROC_REGION_RES_DATA show the memory used by JVM.

...BPK...
1 REPLY 1
Steven Gillard_2
Honored Contributor

Re: C heap size

It depends. If the native methods are simply using malloc() to allocate the memory, then you should look at the size of the data segment. This corresponds to the glance metrc PROC_REGION_VIRT_DATA, which is the total amount of virtual memory used by the processes data segment. The PROC_REGION_RES_DATA gives the amount of physical memory used, ie it is the subset of the virtual region that is resident in physical memory.

The JVM does not use the data segment for its heap. Instead, it allocates an anonymous mmap() segment. This is a bit trickier because a process usually has a number of such segments. If you look at the PROC_REGION_TYPE and PROC_REGION_VIRT metrics, focussing on those which are of type MEMMAP, you will have a list of regions, the java heap being one of these. Usually you can tell by its size (its usually the biggest).

Hope this makes sense.

Regards,
Steve