High CPU usage by hg.exe

Nov 1, 2010 at 4:31 PM

Version 1.1.0 (tried earlier versions too)

I am experiencing the same issue as http://visualhg.codeplex.com/Thread/View.aspx?ThreadId=207693

VisualHG constantly spawns new hg.exe processes which effectively makes Vidual Studio unusable. 

Any ideas or how do I go about debugging this?

Many Thanks 


Nov 2, 2010 at 6:22 PM

Hi Geoff,

it is quite easy to start a debug session.

1) Download and install the MSVS2010 SDK (http://www.microsoft.com/downloads/details.aspx?familyid=47305CF4-2BEA-43C0-91CD-1B853602DCC5&displaylang=en)

2) Clone VisualHG source code (https://hg01.codeplex.com/VisualHG)
3) Load the project and and set under debug options the devenv.exe as executable
You will also find a Readme.txt in the project folder.
This version there is single one timer thread, which is created at start up.
The timer object is located in HGStatus.cs and is started with the method StartDirectoryStatusChecker.
To find out who runs all this hg.exe calls see HG.InvokeCommand(...)
Use also the program 'ProcessExplorer'. It's freeware and it will give you a lot of command line infos of a running task. So you can see which command is exactely called so often to locate the problem.
Let me know if you need further infos and of course if you found out whats happend.
Good luck, Bernd
Nov 2, 2010 at 8:16 PM

Hi Bernd

Thanks for the tips.

I tried running the project in VS but get the message error "No Visual Studio registration attribute found in this assembly". File =  CreatePkgDef. Do you know what that means?

Process Explorer shows that the commands being executed are: "HG.exe" status -A  "hg-checkexec-qj1pis" (the last bit varies each time). The hg.exe processes are constantly started and killed and a never-ending cycle.




Nov 2, 2010 at 9:49 PM

checkexec-qj1pis - strange filename. Virus scanner and indexing service are off for you repo folders?


Like TortoiseSVN, we recommend to turn off the indexing service on the working copies and repositories, and exclude them from virus scans.


Nov 2, 2010 at 10:17 PM

Hi Geoff,

I just found out your files are created by the MS SecurityManager (VirusScanner). For your understanding - I use a DirectoryWatcher which raise

an event on all file changes inside your repo folder. This is to track renames, moves, outside of the studio file changes and so on. If there is

a software who change all the time files inside your repo, all these files have to test against the repo. For now, I don't have a pattern to detect such changes.

I hope that solves your problem




Nov 2, 2010 at 10:52 PM

Hi Bernd

Thanks for your help in trying to track this down. Indexing is off for those folders and I dont have any antivirus software installed.

What is MS SecurityManager? I don't believe I have it installed.





Nov 3, 2010 at 5:49 AM

Hi Bernd

After much trial and error, I've figured it out.

It was the kbfiles mercurial extension that was causing the problem and the simple fix was to remove "kbfiles=C:\Program Files (x86)\Kiln Client\kbfiles" from mercurial.ini. This was installed by the fogcreek kiln client installer. Here are 2 support threads on what kbfiles does: http://kiln.stackexchange.com/questions/1871/i-heard-kiln-added-kbfiles-support-in-2-0-what-does-that-meanhttp://kiln.stackexchange.com/questions/1873/how-do-you-use-bfiles/1874#1874. From the end of the second link:

What Doesn't Work (Yet)

TortoiseHg integration with kbfiles did not make it in Kiln 2.0. You can't corrupt your kbfiles repository with TortoiseHg, but most of the commands will not work. Using TortoiseHg with kbfiles is not recommended even though some parts of it might work.

Some Mercurial commands don't work with kbfiles. For example hg serve won't work correctly. kbfiles repositories can only be pushed or pulled locally or through Kiln. Pushing or pulling through a repository on a networked drive will not work properly.

NOTE: I hadn't specifically converted any repositories to use kbfiles and TortoiseHg continued to work normally outside of Visual Studio and VisualHG.

I'm not sure if this is something you fix or if you need to wait for kbfiles integration into TortoiseHg.

Thanks for your help again. I really like using VisualHG and I've been super impressed with your support too.