BSD-Resource
view release on metacpan or search on metacpan
Resource.pm view on Meta::CPAN
support retrieving the sums of the self and child resource consumptions
simultaneously.
In list context getrusage() returns the current resource usages as a
list. On failure it returns an empty list.
The elements of the list are, in order:
index name meaning usually (quite system dependent)
0 utime user time
1 stime system time
2 maxrss maximum shared memory or current resident set
3 ixrss integral shared memory
4 idrss integral or current unshared data
5 isrss integral or current unshared stack
6 minflt page reclaims
7 majflt page faults
8 nswap swaps
9 inblock block input operations
10 oublock block output operations
11 msgsnd messages sent
12 msgrcv messaged received
13 nsignals signals received
14 nvcsw voluntary context switches
15 nivcsw involuntary context switches
In scalar context getrusage() returns the current resource usages as a
an object. The object can be queried via methods named exactly like
the middle column, I<name>, in the above table.
$ru = getrusage();
print $ru->stime, "\n";
$total_context_switches = $ru->nvcsw + $ru->nivcsw;
For a detailed description about the values returned by getrusage()
please consult your usual C programming documentation about
getrusage() and also the header file C<E<lt>sys/resource.hE<gt>>.
(In B<Solaris>, this might be C<E<lt>sys/rusage.hE<gt>>).
See also L</"KNOWN ISSUES">.
=head2 getrlimit
($nowsoft, $nowhard) = getrlimit($resource);
$rlimit = getrlimit($resource);
The $resource argument can be one of
$resource usual meaning usual unit
RLIMIT_CPU CPU time seconds
RLIMIT_FSIZE file size bytes
RLIMIT_DATA data size bytes
RLIMIT_STACK stack size bytes
RLIMIT_CORE coredump size bytes
RLIMIT_RSS resident set size bytes
RLIMIT_MEMLOCK memory locked data size bytes
RLIMIT_NPROC number of processes 1
RLIMIT_NOFILE number of open files 1
RLIMIT_OFILE number of open files 1
RLIMIT_OPEN_MAX number of open files 1
RLIMIT_LOCKS number of file locks 1
RLIMIT_AS (virtual) address space bytes
RLIMIT_VMEM virtual memory (space) bytes
RLIMIT_PTHREAD number of pthreads 1
RLIMIT_TCACHE maximum number of 1
cached threads
RLIMIT_AIO_MEM maximum memory locked bytes
for POSIX AIO
RLIMIT_AIO_OPS maximum number 1
for POSIX AIO ops
RLIMIT_FREEMEM portion of the total memory
RLIMIT_NTHR maximum number of 1
threads
RLIMIT_NPTS maximum number of 1
pseudo-terminals
RLIMIT_RSESTACK RSE stack size bytes
RLIMIT_SBSIZE socket buffer size bytes
RLIMIT_SWAP maximum swap size bytes
RLIMIT_MSGQUEUE POSIX mq size bytes
RLIMIT_RTPRIO maximum RT priority 1
RLIMIT_RTTIME maximum RT time microseconds
RLIMIT_SIGPENDING pending signals 1
B<What limits are available depends on the operating system>.
See below for C<get_rlimits()> on how to find out which limits are
available, for the exact documentation consult the documentation of
your operating system (setrlimit documentation, usually).
The two groups (C<NOFILE>, C<OFILE>, C<OPEN_MAX>) and (C<AS>, C<VMEM>)
are aliases within themselves.
Two meta-resource-symbols might exist
RLIM_NLIMITS
RLIM_INFINITY
C<RLIM_NLIMITS> being the number of possible (but not necessarily fully
supported) resource limits, see also the get_rlimits() call below.
C<RLIM_INFINITY> is useful in setrlimit(), the C<RLIM_INFINITY> is
often represented as minus one (-1).
In list context C<getrlimit()> returns the current soft and hard
resource limits as a list. On failure it returns an empty list.
Processes have soft and hard resource limits. On crossing the soft
limit they receive a signal (for example the C<SIGXCPU> or C<SIGXFSZ>,
corresponding to the C<RLIMIT_CPU> and C<RLIMIT_FSIZE>, respectively).
The processes can trap and handle some of these signals, please see
L<perlipc/Signals>. After the hard limit the processes will be
ruthlessly killed by the C<KILL> signal which cannot be caught.
B<NOTE>: the level of 'support' for a resource varies. Not all the systems
a) even recognise all those limits
b) really track the consumption of a resource
c) care (send those signals) if a resource limit is exceeded
Again, please consult your usual C programming documentation.
( run in 0.735 second using v1.01-cache-2.11-cpan-e1769b4cff6 )