Using Process.Start in a chain hangs on my computer

I have a strange problem, I created the console application App1, only the purpose of this application is to get the argument (val), if this value is greater than zero, if so, then run the same application (App1) with the argument val-- in the argument and turn off .

I launch this application from a scheduled task, I launch it every minute. The problem is that when I run this application with 1000 as an argument, it hangs on my computer after two or three minutes (blue screen). For an argument like 10, everything works fine.

I need this application to check some memory management problems on another machine.

I ran the following code:

static void Main( string[] args ) { if ( args.Length > 0 ) { int val = 0; try { Int32.TryParse( args[ 0 ], out val ); } catch ( Exception ex ) { } if ( val > 0 ) { val--; ProcessStartInfo psi = new ProcessStartInfo(System.Windows.Forms.Application.ExecutablePath, val.ToString() ); psi.CreateNoWindow = true; psi.WindowStyle = ProcessWindowStyle.Hidden; Process.Start( psi ); } System.Console.WriteLine( args[ 0 ] ); } System.Console.WriteLine( "App" ); } 
+1
source share
1 answer

How exactly do you determine how much memory is available? Are you looking at the "Free" section in the "Physical memory" field in the Windows task manager?

Windows Task Manager is not a memory profiling tool

If so, stop doing it. On my machine, right now this number indicates that I have 6 MB for free. Since I only have 5 GB of RAM, just a few instances of Chrome and VS 2010, I seriously doubt that I used all my RAM.

In fact, you do not need the task manager to perform memory profiling. This answers your last questions . There is absolutely no memory leak, and you do not need to do this stupid regression testing.

+1
source

Source: https://habr.com/ru/post/892223/


All Articles