5

I'm profilling my java application using Windows Performance Analyser. My app is a simple parser, which uses external command-line program to parse files. This external program is called for each file. Here is how it looks when executed in Windows 7:

profiling results

As you can see, there are two short lived processes created simultaneously: conhost.exe and src2srcml.exe. What is weird is that for the first time those processes are alive much longer than later. What can be the cause of this?

Is it possible that Windows caches those processes in some way?

Kao
  • 103

2 Answers2

5

Windows 7 does indeed cache all kinds of files, including applications, in memory. Your guess is probably correct, the fact that the processes are in memory makes them start much more quickly. Not only are the executable files themselves cached, but the DLLs they require are also loaded and ready.

1

conhost.exe is the console-hosting process, that is launched by the Command Prompt (cmd). It is present because you are using a command-line program.

src2srcml.exe is part of the srcML toolkit, and is present probably because you are manipulating Source Markup or XML files.

As to why it is slower on the first call, as was already noted by MoJo, it is because the first call loads nedeed objects into memory. As long as Windows does not require the RAM, it will leave in it all the file-blocks that were read or written.

This includes executable files, DLL files, disk tables, directory structure, user data files, the registry, needed kernel modules, in short anything and everything that resides on the disk is cached by Windows.

The size of the cache is entirely dynamic and may extend to more than half of the RAM. As memory is required by programs, Windows will free blocks that were read. It will also periodically check for the need to write out modified blocks so they can become candidates for freeing (lazy writing), which is why it is not a good idea to pull the power plug on a Windows computer.

This is why newer invocations are faster, because Windows has adapted itself to your needs by loading into RAM all the required objects.

For more information see the Microsoft blogs File Caching or I/O Concepts.

Jason
  • 8,203
harrymc
  • 498,455