[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Debugging Memory Leaks?

» close window

The Question is:

 
Is there a way to find out how much memory each process has used at the current
 time in OpenVMS?
Also, a way to find whether there is a memory leak?
 
 
 
 
 
 


The Answer is :

 
  Please see the existing topics, including (562), (2624), (5341),
  (5640) and (6308).
 
  Discussions in topics such as (1661), (2630), (3115), (3257),
  (3748), (4808), (5455) and (6099) -- and likely various other
  topics -- will be of interest when working with memory management,
  and particularly when debugging memory management problems.
 
  The following example will acquire the current process working
  set (related) values.  (This procedure is arguably the literal
  answer to the question posed.)
 
 
$	context = ""
$	wildcard = "*"
$	if p1 .nes. ""
$	then
$		save_message = f$enviroment( "MESSAGE" )
$		on error then goto restore_message
$		on control_y then goto restore_message
$		set message /nofac /noid /notext /nosev
$		pid = f$getjpi( p1, "PID" )
$		set message 'save_message'
$		if f$type( pid ) .eqs. ""
$		then
$			if f$getsyi( "CLUSTER_MEMBER", p1 )
$			then
$				wildcard = p1
$			else
$				temp = f$context( "PROCESS", context,-
					"USERNAME", p1+"*", "EQL" )
$			endif
$			p1 = ""		! force wildcarding
$		endif
$	endif
 
$	temp = f$context( "PROCESS", context, "NODENAME", wildcard, "EQL" )
 
$	node = ""
$ loop:	if p1 .eqs. "" then pid = f$pid( context )
$	if pid .eqs. "" then exit
 
$	x = f$getjpi( pid, "NODENAME" )
$	if x .nes. node
$	then
$		node = x
$		write sys$output ""
$		write sys$output -
node, "		 Working Set Information"
$		write sys$output -
"                               WS     WS     WS     WS   Pages  Page"
$		write sys$output -
"Username    Processname      Extnt  Quota  Deflt   Size  in WS faults  Image"
$	endif
 
$	uname	= f$getjpi(pid, "USERNAME")
$	if uname .eqs. "" then goto loop
$	pname	= f$getjpi(pid, "PRCNAM")
$	if f$getjpi(pid, "STS") .and. 1
$	then
$	iname	= f$getjpi(pid, "IMAGNAME")
$	iname	= f$parse(iname, , , "NAME")
$	wsdef	= f$getjpi(pid, "DFWSCNT")
$	wsquota	= f$getjpi(pid, "WSQUOTA")
$	wsext	= f$getjpi(pid, "WSEXTENT")
$	wssize	= f$getjpi(pid, "WSSIZE")
$	gpages	= f$getjpi(pid, "GPGCNT")
$	ppages	= f$getjpi(pid, "PPGCNT")
$	pfaults	= f$getjpi(pid, "PAGEFLTS")
$	pages	= gpages + ppages
$	text	= f$fao("!AS!15AS!5(7SL)!7SL!AS",-
			uname,-
			pname,-
			wsext,-
			wsquota,-
			wsdef,-
			wssize,-
			pages,-
			pfaults,-
			" "+iname)
$	else
$	text	= f$fao("!AS!15AS --  swapped  out  --", uname, pname)
$	endif
$	write sys$output text
$	if p1 .eqs. "" then goto loop
$	exit
 
$ restore_message:
$		set message 'save_message'
 

answer written or last revised on ( 5-SEP-2001 )

» close window