This section describes how to set a limit on the memory usage on the master and workers.
Two ways are available:
- using the system call setrlimit to set soft and/or hard limits handled by the system;
- apply a soft check on the process memory consumption while looping on the entries to process (workers only).
The two sort of limits can be enabled at the same time.
Setting system limits
System limits are set when starting the proofserv application. They are controlled by the following environment variables:
- ROOTPROOFASSOFT
Soft limit (in setrlimit terms) in MBytes on the virtual memory (address space); automatic stack expansion will fail (and generate a SIGSEGV that kills the process; since the value is a long, on machines with a 32-bit long either this limit is at most 2 GiB, or this resource is unlimited. - ROOTPROOFASHARD
Hard limit for the the soft limit above; this should be used to avoid users to increase their soft limit to infinite. See documentation of setrlimit.
These variables must be set via the xproofd configuration file using the xpd.putenv directive. For examples, the following sets limits to 2GBytes:
xpd.putenv ROOTPROOFASSOFT=2047
xpd.putenv ROOTPROOFASHARD=2047
Soft limits per event
It is also possible to set soft limits checked by the application (proofserv) itself on by-event bases. These limits can address the virtual and resident memory and are also controlled by the following environment variables:
- PROOF_RESMEMMAX
Upper limit in kBytes on the resident memory used by the process; the value against which the limit is checked is the one returned by TSystem::GetProcInfo . - PROOF_VIRTMEMMAX
Upper limit in kBytes on the virtual memory used by the process; the value against which the limit is checked is the one returned by TSystem::GetProcInfo .
Once the limits are reached processing is terminated gracefully on the worker. Note that this limits will allow to detect regular memory leaks: huge allocations during entry processing (for example due to corrupted number of bytes) will not be protected against by these upper limits, and can only be handled by the system.
Example: the following sets limits to 800 MBytes and 1600 MBytes on resident and virtual memory, respectively:
xpd.putenv PROOF_RESMEMMAX=800000
xpd.putenv PROOF_VIRTMEMMAX=1600000