Re: [Mono-dev] Mono - CreateProcess error

2006-09-26 Thread Brian Crowell
Honey, Steve wrote:
> Help!

Hey, Steve. I've been watching this one, too. For months.

The latest bug is filed as:

   http://bugzilla.ximian.com/show_bug.cgi?id=79286

The only workaround I know of at this point (other than, say, rebooting every 
now and then) is to periodically empty the contents of the ~/.wapi directory. 
You can do this while the program's running, say, every ten minutes, or just as 
you've finished one run of data.

At least, I *think* that works. It's such a finicky problem, I can never be 
sure 
of a real fix.

--Brian
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Mono - CreateProcess error

2006-09-26 Thread Brian Crowell
Brian Crowell wrote:
> At least, I *think* that works. It's such a finicky problem, I can never be 
> sure 
> of a real fix.

Check that. We just received reports in this morning from our application. This 
doesn't clear or disable WAPI at all.

Looks like the next alternative would be to shut down the Mono process, delete 
the contents of ~/.wapi, and restart the Mono process.

--Brian
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Mono - CreateProcess error

2006-09-26 Thread Miguel de Icaza
Hello,

> A search of google says this was a bug which was supposed to be
> corrected in 1.1.16.  I was running 1.1.13 so I upgraded to 1.1.17 but
> still have the problem.  I also tried adding Process.Dispose() to the
> code but that hasn’t help either (don’t know if it should have, but
> I’m desperate).  
> 
>  
> 
> Are there other workarounds I can try?  (I need to make system calls
> from the application)

One possible workaround is to not use the CreateProcess which consumes
these wapi handles but instead P/Invoke into "system" or g_spawn.

I wonder if you are calling too many processes in quick succession, so
its just a matter of not enough time to clean up those handles/.

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Mono - CreateProcess error

2006-09-26 Thread Robert Jordan
Honey, Steve wrote:
> A search of google says this was a bug which was supposed to be
> corrected in 1.1.16.  I was running 1.1.13 so I upgraded to 1.1.17 but
> still have the problem.  I also tried adding Process.Dispose() to the
> code but that hasn't help either (don't know if it should have, but I'm
> desperate).  

Try calling proc.WaitForExit() if you don't already.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Mono - CreateProcess error

2006-09-26 Thread Brian Crowell
Miguel de Icaza wrote:
> I wonder if you are calling too many processes in quick succession, so
> its just a matter of not enough time to clean up those handles/.

That's not the case. I've had long-running programs that would wait several 
minutes between invocations, and they also suffer from this.

As I explain in the bug report, even creating a Process and failing to call 
Dispose will not cause a problem by itself. Yes, there may be more Process 
handles in the table at once, but the garbage collector is pretty quick at 
cleaning them up, and the most I've seen in the table this way is maybe twenty, 
a far cry from the table's limit of 4096.

No, the handle leak problem happens regardless of how the C# program chooses to 
treat its resources. Disposing of the Process object will clean up most handles 
instantly, but regardless of whether you call Dispose, some handles will be 
leaked. And if your program runs for a long time, it will eventually hang the 
Mono process.

--Brian
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Mono - CreateProcess error

2006-09-26 Thread Honey, Steve
Same here regarding the frequency of the invocations.  

My application makes the call once every 4 minutes or so.
I run 45 of these applications (each processing a different radar site)
and I start having problems after 8 hours of constant running.

Steve

-Original Message-
From: Brian Crowell [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 26, 2006 2:12 PM
To: Miguel de Icaza
Cc: Honey, Steve; mono-devel-list@lists.ximian.com
Subject: Re: [Mono-dev] Mono - CreateProcess error

Miguel de Icaza wrote:
> I wonder if you are calling too many processes in quick succession, so
> its just a matter of not enough time to clean up those handles/.

That's not the case. I've had long-running programs that would wait
several 
minutes between invocations, and they also suffer from this.

As I explain in the bug report, even creating a Process and failing to
call 
Dispose will not cause a problem by itself. Yes, there may be more
Process 
handles in the table at once, but the garbage collector is pretty quick
at 
cleaning them up, and the most I've seen in the table this way is maybe
twenty, 
a far cry from the table's limit of 4096.

No, the handle leak problem happens regardless of how the C# program
chooses to 
treat its resources. Disposing of the Process object will clean up most
handles 
instantly, but regardless of whether you call Dispose, some handles will
be 
leaked. And if your program runs for a long time, it will eventually
hang the 
Mono process.

--Brian

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Mono - CreateProcess error

2006-09-28 Thread Hubert FONGARNAND




Le mardi 26 septembre 2006 à 20:03 +0200, Robert Jordan a écrit :


Honey, Steve wrote:
> A search of google says this was a bug which was supposed to be
> corrected in 1.1.16.  I was running 1.1.13 so I upgraded to 1.1.17 but
> still have the problem.  I also tried adding Process.Dispose() to the
> code but that hasn't help either (don't know if it should have, but I'm
> desperate).  

Try calling proc.WaitForExit() if you don't already.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


I've written a little program that could help people that having problems with Handles...

It display all process handles, with their associated threads...

I hope it could help!
___Ce message et les éventuels documents joints peuvent contenir des informations confidentielles.Au cas où il ne vous serait pas destiné, nous vous remercions de bien vouloir le supprimer et en aviser immédiatement l'expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.Les communications sur internet n'étant pas sécurisées, l'intégrité de ce message n'est pas assurée et la société émettrice ne peut être tenue pour responsable de son contenu.

// project created on 27/09/2006 at 12:05
using System;
using System.Diagnostics;
using System.Collections;
using System.Text;
using Mono.Posix;
using Mono.Unix;
using System.IO;
using System.Text.RegularExpressions;

namespace wapi_analyser
{
	class MainClass
	{
		
		Hashtable process=new Hashtable();
		Hashtable threads=new Hashtable();
		
		public static void Main(string[] args)
		{
			MainClass main=new MainClass();
			main.Analyse(main.GetData());
			main.Display();
		}
		
		public void Display()
		{
			foreach (int pid in process.Keys)
			{
// Récupération de la ligne de commande:
	string filename="/proc/"+pid+"/cmdline";
string cmdline="";
try
{
	StreamReader re = File.OpenText(filename);
	cmdline=re.ReadToEnd();
}catch {}
Console.WriteLine("Pid : "+pid+" Nom :"+process[pid]+" cmd : "+cmdline+" Nb threads :"+GetNbThread(pid));

			}
			
		}
		
		public int GetNbThread(int pid)
		{
			int counter=0;
			foreach (string id in threads.Keys)
			{
if (((int)threads[id])==pid)
	counter++;
			}
			return counter;
			
		}
		
		
		
		public void Analyse(string stringdata)
		{
			string[] rawtable=stringdata.Split('\n');
			Console.WriteLine(rawtable.Length+" Handle");
			ArrayList sortedtable=new ArrayList();
			bool record=false;
			foreach (String line in rawtable)
			{
if (line.StartsWith("collection"))
	record=true;
if (line.Trim().StartsWith("Fileshare"))
{
	record=false;
}
if (record)
	sortedtable.Add(line);
// Check if this is a process
if (line.IndexOf("[Process]")!=-1)
{
	//Console.WriteLine("Process");
	// Extraction du nom du process
	string pattern=@"\[\s+.*]";
	Match match= Regex.Match(line,pattern);
	
	string processname=match.ToString();
	processname=processname.Trim(new char[]{'[',']'}).Trim();
	//Console.WriteLine(processname);
	// Extraction du pid
	pattern=@"pid:\s*\S*\s";
	match= Regex.Match(line,pattern);
	string pid=match.ToString();
	pid=pid.Replace("pid: ","");
	//Console.WriteLine(pid);
	try{
	int pidint=int.Parse(pid);
		process.Add(pidint,processname);
	}catch
	{
		Console.WriteLine("Erreur while parsing "+pid);
		Console.WriteLine("Ligne "+line);
	}
	
}
if (line.IndexOf("[ Thread]")!=-1)
{
	//Console.WriteLine("Thread");
	// Extraction du thread id
//	string pattern=@"tid:\s\S*,";
//	Match match= Regex.Match(line,pattern);
//	string tid=match.ToString();
//	tid=tid.Replace("tid: -","");
//	tid=tid.Replace(",","");
//	int tidint=int.Parse(tid);
	//Console.WriteLine(tidint);
	// Recherche du pid du process
	string pattern=@"proc:\s\S*,";
	Match match= Regex.Match(line,pattern);
	string proc=match.ToString();	
	proc=proc.Replace("proc: ","");
	proc=proc.Replace(",","");
	int procint=int.Parse(proc);
	//Console.WriteLine(procint);
	threads.Add(Guid.NewGuid().ToString(),procint);
}




			}
			//Console.WriteLine(sortedtable.Count);
			
		}
		
		
		public string GetData()
		{
			Process process=new Process();
			ProcessStartInfo info=new ProcessStartInfo();
			info.FileName="/usr/bin/mono";
			info.Arguments="--wapi=hps";
			info.UseShellExecute = false;
info.RedirectStandardOutput = true;
			info.RedirectStandardError = true;
			process.StartInfo=info;
			process.Start();
			string sortie=process.StandardOutput.ReadToEnd();
			process.WaitForExit();
			//Console.WriteLine(sortie);
			return s