0

I encounter a strange problem when calling a R script with C#. The Console App works perfectly on our dev and preprod machines, but not in the production server. In production, the R process is blocked after a few minutes, the console never close without any Exceptions.

The only difference I see is that the production server is more powerful, has more RAM and more cores (8 cores and 16GB RAM, WindowsServer 2008R2).

After a few tests, I understand that if I force R to use only 2 cores, it's works! And if I call directly the same R script with Rscript.exe from .bat, it's works! (but I want to use 8 cores and class from C# with my business rules..)

Here is the C# code. Does C# limit the max memory when we call a .exe with the Process class ? (the R script use a lot of memory) Or any other idea ?

Thanks a lot for your help

    private Process ExecuteCommand()
    {
        string command = @"Rscript --vanilla --verbose launcher.r";

        ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command);

        procStartInfo.WorkingDirectory = "C:\Program Files\RRO\R-3.2.2\bin\x64";
        procStartInfo.RedirectStandardOutput = true;
        procStartInfo.UseShellExecute = false;
        procStartInfo.CreateNoWindow = false;
        procStartInfo.RedirectStandardInput = true;
        procStartInfo.RedirectStandardError = true;
        procStartInfo.StandardOutputEncoding = Encoding.UTF8;
        procStartInfo.StandardErrorEncoding = Encoding.Default;

        Process processus = new Process();
        processus.StartInfo = procStartInfo;
        processus.Start();

        return processus;
    }
twisted
  • 59
  • 1
  • 9

0 Answers0