This project is read-only.

R.NET startup parameter MaxMemorySize ignored

Nov 29, 2013 at 11:18 AM

I'd like to limit the memory for my R engine. I tried using:

engine.Initialize(new StartupParameter() { MaxMemorySize = n }) ;

with various values for "n"

later I did

and the value returned was always 2047 as if the passed memory limit was always ignored.

I am using latest R.NET with latest R 3.0.

is this a known bug or is there a different way to set the memory limit?
Nov 29, 2013 at 12:03 PM
This is probably not a known bug, but given a recent dive into the R engine initialization this would not surprise me there is an issue. I got a case where the Interactive startup parameters looked ignored or overridden by R in some circumstances.

Are you working on Windows? the code is significantly different for Windows vs Unix, so just to know.

I'll look at adding unit tests covering the issue you report, but probably cannot do that for at least a week
Nov 29, 2013 at 1:36 PM
I am using Windows. It is also strange that R GUI run without params gives me a different memory limit than R.NET.
Nov 29, 2013 at 9:47 PM
I have logged an issue at I can reproduce the issue even on the latest (rev 241) development code I work on (branch 'jperraud') with a revised engine initialization procedure.

All I can see in debug mode on the C# side in REngine.Initialize looks like it is passing the right information to the native R engine (I cannot step through native code), so why the information appears lost thereafter is unknown.

Mixed-mode .NET+native debugging with Visual Studio would be a blessing to sort out these issues, but R is not compilable with Visual C++.

By the way if someone 'out there' feels up to it to figure out this issue, I'd gladly do with some help.
Nov 29, 2013 at 10:28 PM
Are you now initializes by passing strings or did you change your branch to pass the struct still? will try to look at this later as part of the --no-save/vanilla issue from earlier.
Nov 30, 2013 at 12:20 AM
I am calling Rf_initialize with command line arguments, and then passing the starting parameters still. I appeared to need to do both on Linux to get it to work in an MPI application, and this seemed to be what RInside is doing too. I am not even sure whether the struct passing is successful on Linux, really; it just is that the issue in an MPI context is resolved.

the C code for Rf_initialize_R for 'unix/system.c' and 'gnuwin32/embeddR.c' are quite different, with the former doing a lot more than the latter. I cannot even see the windows version doing anything to analyse the command line arguments.

By the way I think the latest code should solve your prior issue with --no-save/vanilla, but this is not verified.
Dec 9, 2013 at 7:08 PM
The latest commit (initializing by passing strings instead of the struct), does appear to fixe the --no-save/vanilla issue, thanks much for the changes!