Execution hangs at controller constructor

Questions about YourKit .NET Profiler
Post Reply
sandeep
Posts: 24
Joined: Wed May 16, 2012 3:08 pm

Execution hangs at controller constructor

Post by sandeep »

I use Controller() to see if a particular process has YourKit agent attached to it. Sometimes the function never returns for certain process ids. That last time it happened, I checked which process it freezes at, and it was calc.exe.

I tried to reproduce the problem by closing and starting another instances of windows calculator application, but I was unable to get it to freeze.

Previously, I have had the same problem when using overloaded controller constructor that uses hostname and agent port. - Controller(String, Int32)
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Execution hangs at controller constructor

Post by Anton Katilin »

How did you get the PID list?

Do you mean you enumerated all processed on the machine and applied the Controller(int pid) constructor to each PID?
sandeep
Posts: 24
Joined: Wed May 16, 2012 3:08 pm

Re: Execution hangs at controller constructor

Post by sandeep »

Yes. Is there any other way?
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Execution hangs at controller constructor

Post by Anton Katilin »

Check only those processes for which the profiler agent log file exists.

The following pseudo-code illustrates how to do it:

Code: Select all

int[] allPIDs = ...; // get all PIDs as you do it now
foreach (int pid in allPIDs)
{
   if (File.Exists("<user home directory>/.ynp/log/" + pid + ".log)) {
      // ... perform the check with new Controller() as you do it now...
   }
}
Please don't forget to replace <user home directory> with the home directory under which the applications to be detected has been started.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Execution hangs at controller constructor

Post by Anton Katilin »

Also, you can periodically cleanup the log file directory <user home directory>/.ynp/log to reduce probability to hit an old log file created for a finished application whose PID by chance matches the PID of one of the currently running processes which are not started with the profiler.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Execution hangs at controller constructor

Post by Anton Katilin »

By the way, could you please explain your intention. Why do you need to list all processes with the agent loaded?
sandeep
Posts: 24
Joined: Wed May 16, 2012 3:08 pm

Re: Execution hangs at controller constructor

Post by sandeep »

Anton Katilin wrote:By the way, could you please explain your intention. Why do you need to list all processes with the agent loaded?
We using it to auto-collect all snapshots at real-time and store them in a centralized data store, so people can go back to any time and see how the application was performing
sandeep
Posts: 24
Joined: Wed May 16, 2012 3:08 pm

Re: Execution hangs at controller constructor

Post by sandeep »

Anton Katilin wrote:Check only those processes for which the profiler agent log file exists.

The following pseudo-code illustrates how to do it:

Code: Select all

int[] allPIDs = ...; // get all PIDs as you do it now
foreach (int pid in allPIDs)
{
   if (File.Exists("<user home directory>/.ynp/log/" + pid + ".log)) {
      // ... perform the check with new Controller() as you do it now...
   }
}
Please don't forget to replace <user home directory> with the home directory under which the applications to be detected has been started.
Thanks. I think this method is a bit more efficient also.
Post Reply