From jeroenooms at gmail.com  Tue May 10 01:08:00 2016
From: jeroenooms at gmail.com (Jeroen Ooms)
Date: Tue, 10 May 2016 01:08:00 +0200
Subject: [Rd] R process killed when allocating too large matrix (Mac OS
	X)
In-Reply-To: <572B14D9.3050005@stats.ox.ac.uk>
References: <CAM3-KjYqc5CvDt4yKkOEPw--1Fq-c8O8x6UfFir5x==-UwFYvw@mail.gmail.com>
	<0e0160ec793649dda463b43d7e7d5c37@CONNHUB1.connect.uwaterloo.ca>
	<CAM3-Kja40deG=04U+PDNjLD=sHzQRiz_umia+wBEP77YyW5qQA@mail.gmail.com>
	<9b3da5c7758b455baad7209384abe7a7@CONNHUB4.connect.uwaterloo.ca>
	<CAM3-KjZ13TOz7x6DC+F1=9WsJFHbz4Ay0gf-fhQOv84oSRiE=w@mail.gmail.com>
	<308D9A3B-C40F-4AF7-AF1A-43DC8E1130EF@r-project.org>
	<572AA6AF.9040400@fredhutch.org>
	<3e8b8d2d46ac440892d2055c502b5be9@CONNHUB1.connect.uwaterloo.ca>
	<CAM3-KjbDejim0PSj9s5ognw4wfA=_BvD2UmfVDdmixqww2MkoA@mail.gmail.com>
	<2fa1c8e2-c692-1237-ea3c-572397038b26@statistik.tu-dortmund.de>
	<572B14D9.3050005@stats.ox.ac.uk>
Message-ID: <CABFfbXtm5hOW+ah_bjtnP5QproRnGXBtPUsKDK54SXqGfQu=Qg@mail.gmail.com>

On 05/05/2016 10:11, Uwe Ligges wrote:
> Actually this also happens under Linux and I had my R processes killed
> more than once (and much worse also other processes so that we had to
> reboot a server, essentially).

I found that setting RLIMIT_AS [1] works very well on Linux. But this
requires that you cap memory to some fixed value.

> library(RAppArmor)
> rlimit_as(1e9)
> rnorm(1e9)
Error: cannot allocate vector of size 7.5 Gb

The RAppArmor package has many other utilities to protect your server
such from a mis-behaving process such as limiting cpu time
(RLIMIT_CPU), fork bombs (RLIMIT_NPROC) and file sizes (RLIMIT_FSIZE).

[1] http://linux.die.net/man/2/getrlimit



[Rd] R process killed when allocating too large matrix (Mac OS X)
Jeroen Ooms