It's seldom to create a process without doing anything like this, because a
process may like another program run in the memory. In your example, the
"bob" object will be disposed after the main app exit, but the program (or
the process) that "bob" raised will run until it finishes.

And the last one, you cannot start a process without supplying the process's
FileName. The appropriate code may be:

Process bob = new Process();
            bob.StartInfo.FileName = @"C:\test.txt";
            bob.Start();

OR:
Process .Start(@"C:\test.txt");
.

On Tue, Aug 25, 2009 at 8:18 AM, Benj Nunez <[email protected]> wrote:

>
> I see. Well, I'm referring to the bob object that was instantiated:
>
> System.Diagnostics.Process bob = new System.Diagnostics.Process();
>
> Will bob remain in memory after I exit the main app?
> Just to be sure, I had to do put the code under the try..finally
> block:
>
>
> System.Diagnostics.Process bob = null;
> try
> {
>    bob = new System.Diagnostics.Process();
> }
> catch ()
> {
>  ...
> }
> finally
> {
>   if (bob != null)
>   {
>       bob.Close();
>   }
> }
>
>
> Am I doing this correctly? Please advise.
>
>
>
> Benj
>
>
> On Aug 24, 4:55 pm, Petr Syromolotov <[email protected]>
> wrote:
> > The process you've started will continue executing and occupying memory.
> > So from some point of view it's a "memory leak".
> >
> > On Mon, Aug 24, 2009 at 12:36 PM, Benj Nunez <[email protected]>
> wrote:
> >
> > > Good afternoon experts,
> >
> > > I need your input regarding a situation like this:
> >
> > > Suppose there's a code that spawns a process (invoke the Console
> > > window) like this:
> >
> > > System.Diagnostics.Process bob = new System.Diagnostics.Process();
> > > bob.StartInfo.UseShellExecute = true;
> > > bob.StartInfo.Arguments += " /K TITLE Command Prompt";
> > > bob.StartInfo.FileName = "CMD";
> > > bob.Start();
> >
> > > And then, I deliberately close the main app that has the code above,
> > > what will
> > > happen to the process? Will it produce a memory leak?
> >
> > > Benj
>



-- 
kidVN

Reply via email to