From lbert@cco @ending from ti@c@li@it  Mon Oct  1 18:29:56 2018
From: lbert@cco @ending from ti@c@li@it (Livio Bertacco)
Date: Mon, 1 Oct 2018 18:29:56 +0200
Subject: [Rd] unexpected memory.limit on windows in embedded R
Message-ID: <CAL0dvtjUwjxgVxqJi=XeEroYTA+Hs33H98ZifiUw2B0eHZ6WQw@mail.gmail.com>

Dear All,
I'm linking R from another application and embedding it as described in the
R-exts manual, i.e. with initialization done via Rf_initEmbeddedR.
While everything works the same as in standalone R for Linux, under Windows
I found a difference in the default memory.limit, which is fixed to 2GB
(both win32 and win64) - compared to a limit in standalone R of 3.5GB for
win32 and 16GB on win64 (which is the amount of physical memory I have).

So I wonder if this is just undocumented (at least, I couldn't find any
mention of it) or unintentional.
All I could find is the following:
- man page of memory.limit doesn't mention a default 2GB limit, especially
not on win64;
- man page of memory.limit and rw-FAQ Q2.9 say that you can set the limit
via --max-mem-size or R_MAX_MEM_SIZE env var: both work only in standalone
R (Rf_initEmbeddedR ignores them);
- R\src\gnuwin32\system.c defines
    R_size_t R_max_memory = INT_MAX;
  which is the reason of the 2GB default limit on embedded R; however
INT_MAX is not the maximum integer value of an R_size_t variable either on
win32 nor on win64;
- line 879 of the same system.c source says: "/* set defaults for
R_max_memory. This is set here so that embedded applications get no limit
*/" (meaning that that code is executed only for standalone R) which
suggests that, at some point, the intention for embedded R was to impose no
limit by default and maybe the INT_MAX value is a mistake.

Thank you in advance,
Livio

	[[alternative HTML version deleted]]



[Rd] unexpected memory.limit on windows in embedded R
Livio Bertacco