[mpich-discuss] Large memory allocations in MPI applications under Linux

Jed Brown jed at 59A2.org
Wed Apr 15 13:00:32 CDT 2009


On Wed 2009-04-15 13:09, Sudarshan Raghunathan wrote:
> I am wondering if there is any way to restructure/rewrite my
> application (or tweak settings for malloc), so that irrespective of
> how many processes I'm running with, I get a null-pointer exception on
> at least a subset of the ranks as soon as the total physical memory is
> exhausted. The "obvious" solution is to look at /proc/meminfo to see
> the physical amount of available memory and allocate only if
> sufficient memory is available, but this seems to be highly
> sub-optimal and fragile.

A lightweight solution is to set `ulimit -v' in your shell.
Alternatively, look at setrlimit (2), RLIMIT_AS.  This limits the total
amount of virtual memory available to your process.  If you try to
malloc beyond this limit, it will fail (return NULL).

Most kernels are configured to have no problem wildly over-committing
memory.  I can malloc 10GB on a machine with 4 GB memory and 4 GB swap.
Clearly I can't actually touch all of that memory, but malloc doesn't
mind.  This is a feature and disabling overcommitment may cause problems
for other programs (depending on what else is running on your machine).

Jed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20090415/e64a8066/attachment.pgp>


More information about the mpich-discuss mailing list