Sponsored Content
Top Forums Programming Measuring memory used by a program? Post 302258573 by jim mcnamara on Friday 14th of November 2008 10:51:36 PM
Old 11-14-2008
The process itself can call getrusage via JNI but the OS has to support getrusage first.If getrusage is not there then you can try opening /proc/self/status like a text file and read the values stored in there:
VmSize: 12084 kB
VmLck: 0 kB
VmRSS: 10280 kB
VmData: 9636 kB
VmStk: 188 kB
VmExe: 72 kB
VmLib: 2112 kB

Corona mentions a problem: the JVM process. You may need to get the pid of your process via a call to ps. Then access your values via pstat or the /proc filesystem or however your OS works.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Program/ Memory Problems

I need some advise. I have an application server running several applications. When I try and start a particular application when the others are running I receive the following. This is appearing in the core file that is created. ... (1 Reply)
Discussion started by: dbrundrett
1 Replies

2. Shell Programming and Scripting

Program to find CPU,memory and I/O utilization

Can anyone please help me regarding this .sh script: The shell script should monitor CPU,memory and I/O utilization continuously after a defined time interval and should write it in an output file like excell. (1 Reply)
Discussion started by: Subhayan
1 Replies

3. Programming

how to check memory leak in C program under Unix

Hi, How to detect memory leak in C program under unix ? Thanks (6 Replies)
Discussion started by: useless79
6 Replies

4. Solaris

How to know the size of the program currently executing in memory

hey everybody, i am currently working on solaris 10 os on a m5000 server. my problem is when i want the exact size of a program in execution, i am unable to do it. earlier i thought the RSS field of prstat but because of its large size it cant be the size. pmap -x shows some output but it includes... (2 Replies)
Discussion started by: aryansheikh
2 Replies

5. Programming

Current and Peak Memory consumption of my program?

Hi, my C++ program does some memory consuming tasks and runs several minutes. During execution time, I want to print information on the current memory consumption and peak memory consumption of my program into a logfile. How can I retrieve this information, i.e. which functions are available... (0 Replies)
Discussion started by: DarthVader77
0 Replies

6. Programming

Memory Fault (core dumped) in ttpy program

I´m writing this program in QNX , I`m kinda new to UNIX and programing in general, and when I try to run it it gives me the Memory Fault error. Can anyone help? #include <stdio.h> #include <fcntl.h> void main(void) {int a,ter; char buf; printf("a="); scanf("%d",a); ter=open... (6 Replies)
Discussion started by: GiganteAsesino
6 Replies

7. AIX

Memory limit for C program

Greetings - I'm porting a C application to an AIX (6.1) system, and have bumped into the limits AIX imposes on memory allocation, namely the default limit of 256MB for a process. I'm aware of the compilation flag that allows an application to gain access to up to 8 memory segments (each 256MB,... (4 Replies)
Discussion started by: traviswheeler
4 Replies

8. Programming

Shared memory between two c program

i have to shared a variable between two different c programs with shared memory and i do these: int main() { int a=5,b=7; int buffer; int *point; int shmid; shmid=shmget(IPC_PRIVATE , sizeof(buffer),0666); point=(int *)shmat(shmid,NULL,0); point=a; ... (21 Replies)
Discussion started by: tafazzi87
21 Replies

9. Programming

Help regarding memory leak in this C program

I have written this code in C which reads a very large collection of text files and does some processing. The problem with this code is that there are memory leaks which I am not able to figure out as to where the problem is. When I run this code, and see the memory usage using top command, then I... (7 Replies)
Discussion started by: shoaibjameel123
7 Replies

10. Programming

Size of memory used by a program

Hello, Here is a portion of my code: a=(int *) malloc(dim*dim*sizeof(int)); b=(int *) malloc(dim*dim*sizeof(int)); c=(int *) malloc(dim*dim*sizeof(int)); for(i=0;i<dim;i++) for(j=0;j<dim;j++) c= rand(); for(i=0;i<dim;i++) for(j=0;j<dim;j++) b=rand(); ... (6 Replies)
Discussion started by: chercheur111
6 Replies
getrusage(2)							System Calls Manual						      getrusage(2)

NAME
getrusage, vtimes - Gets information about resource utilization LIBRARY
Berkeley Compatibility Library (libbsd.a): vtimes() only SYNOPSIS
#include <sys/resource.h> int getrusage( int who, struct rusage *r_usage); [Tru64 UNIX] The following function declaration does not conform to current standards and is supported only for backward compatibility: #include <sys/vtimes.h> vtimes( struct vtimes *par_vm, struct vtimes ch_vm); [Tru64 UNIX] Application developers using the getrusage() function may want to specify an #include statement for <sys/time.h> before the one for <sys/resource.h> if programs are being developed for multiple platforms. The additional #include statement is not required on Tru64 UNIX systems or by ISO or X/Open standards, but may be required on other vendors' systems that conform to these standards. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: getrusage(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies one of the following: Retrieve information about resources used by the current process. Retrieve information about resources used by terminated and waited for child processes of the current process. Points to a buffer that will be filled in as described in the <sys/resource.h>. DESCRIPTION
The getrusage() function returns information describing the resources used by the current process or its terminated or waited for child processes. If the child process is never waited for, for example if the parent has set SA_NOCLDWAIT or has SET SIGCHLD to SIG_IGN, the resource information for that child process is discarded. NOTES
The numbers the ru_inblock and ru_outblock fields of the rusage structure account only for real I/O; data supplied by the caching mechanism is charged only to the first process to read or write the data. [Tru64 UNIX] The vtimes() function returns accounting information for the current process and for the terminated child processes of the current process. Either par_vm or ch_vm or both may be zero, in which case only the information for the pointers which are nonzero are returned. After the call, each buffer contains information as defined by the contents of the sys/vtimes.h include file. RETURN VALUES
Upon successful completion, the getrusage(), function returns 0 (zero). Otherwise, the function returns -1 and sets errno to indicate the error. ERRORS
The getrusage() function sets errno to the specified values for the following conditions: The who parameter is not a valid value. [Tru64 UNIX] The address specified for r_usage is not valid. RELATED INFORMATION
Functions: wait(2) Routines: gettimer(3), time(3), times(3) Standards: standards(5) delim off getrusage(2)
All times are GMT -4. The time now is 12:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy