[Mono-dev] I: Re: System.Diagnostics.Process.Start() crashes when trying to allocate more than 255 processes
fcolle at libero.it
fcolle at libero.it
Tue Jun 14 02:47:27 EDT 2011
Yes, Tom, I think it could be the problem.For the moment I solved with a workaround. I changed the architecture and made up threads instead of processes. Anyways I think there are several situations where having more than 255 processes is possible.Another difference I noticed is that when you create child processes and kill the main program, under windows the processes are killed, whereas they continue to live on linux.
Tom wrote:Might it have to do with the fact that Mono only allows 256 shared handles?
See _WAPI_HANDLE_INITIAL_COUNT in wapi-private.h and the "/* FIXME: grow
the arrays */" in handles.c _wapi_handle_real_new().
We ran into a problem like this on a build box that exec'd a lot of
processes but we worked around it by using GC.Collect();
GC.WaitForPendingFinalizers(); GC.Collect(); to clean up the handles.
Tom
----Messaggio originale----
Da: fcolle at libero.it
Data: 13/06/2011 16.10
A: <mono-devel-list at lists.ximian.com>
Ogg: System.Diagnostics.Process.Start() crashes when trying to allocate more than 255 processes
Dear all,
my linux application needs to start a big number (400) of processes. Each process is a mono application.
I found the when trying to run more then 255 processes the runtime generates an exception.
The problem does NOT arise when executing other processes, like e.g. bash.
Example
The following two executables classes are a simple proof of concept.
Just compile the second class and put in into the /tmp folder
MAIN PROGRAM
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace CrashTester
{
class Program
{
static void Main(string[] args)
{
///In the real application this dictionary
/// contains useful data. When a process dies,
/// it can be started again with the same input parameters
try
{
for (int i = 0; i < 260; i++)
{
Console.Error.WriteLine("STARTING PROCESS: "+(i+1).ToString());
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.FileName = "/usr/local/bin/mono";
startinfo.Arguments = "/tmp/ToCrash.exe "+(i+1).ToString();
startinfo.UseShellExecute = false;
startinfo.RedirectStandardError = false;
startinfo.RedirectStandardOutput = false;
Process p = new Process();
p.StartInfo = startinfo;
p.Start();
}
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
Console.Error.WriteLine("ERROR IN START PROCESS!");
}
Console.ReadKey();
}
}
}
CHILD PROCESSES
using System;
using System.Collections.Generic;
using System.Text;
namespace ToCrash
{
class Program
{
static void Main(string[] args)
{
if((args!=null)&&(args.Length>0))
{
Console.WriteLine(args[0]);
}
Console.ReadLine();
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110614/fba76f52/attachment.html
More information about the Mono-devel-list
mailing list