1

I'm using Visual Studio 2010 to write and debug a small program. The problem is, whenever I start the application through Visual Studio 2010 the process of my application produces page-faults in the range of 100000 per second and that slows down the program by factor 10 or more. When I start the generated executable from the file system no page-faults are generated after the start-up is complete. That happens with the debug and the (all optimizations allowed) release build. No exceptions are getting thrown.

The program itself is compiled around 200kib and when executed holds around 10mib of data with over 4gib of memory available. There are only the main thread and the thread of the logging framework running. The data is loaded once at the start and after that only the results are stored in newly allocated memory and written to the log at the end.

There does not seem to be a lot of disk activity and the Windows Resource Monitor indicates no hard faults, while the Task Manager shows ever increasing numbers. I know that some performance loss is to be expected for using an IDE, but this seems a little bit excessive. Any advice?

Edit:

Note: I was able to get the count down to about half by cutting down on (de-)allocating new memory.

Process Explorer says: Process Explorer

It seems the debugger is at fault. If I do not attach it, it behaves as expected. Although I'm still wondering why it would provoke such a high amount of page faults, that it slows down all builds considerably.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Darcara
  • 1,598
  • 1
  • 13
  • 33
  • have you tried using Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645 to see what is actually happening? – Mark Hall Jul 30 '11 at 17:59
  • Hmm, it is not possible to start a program and not get page faults. This would indicate that your observations are not accurate. How many 'first chance' exception notifications do you see in the Output window? – Hans Passant Jul 30 '11 at 18:08
  • @Mark: Thanks, I had not. Anything I should look for, because after the startup the only things I see are the writes to the log file. Especially nothing that would be different if run outside of Visual Studio. – Darcara Jul 30 '11 at 18:09
  • @Hans: True, I get the a few page faults at the start (~100000), but I omitted that, because it's normal. No Exceptions. – Darcara Jul 30 '11 at 18:12
  • Are you saying that a large number of page faults are occurring only while running your program in the debugger? Does it occur in the release build in the debugger? At this point, I'm guessing this is how the debugger works. – Mike Jul 30 '11 at 18:50
  • Yes, I get around 100k page faults when the application is starting up and then around 100k every second while running. Happens in all builds, but only when started from within VS2010 – Darcara Jul 30 '11 at 19:05
  • @Darcara there is at least two ways to run the project in Visual Studio (with the debugger attached and not attached). If you run it not attached, then what is the page fault rate? – Mike Jul 30 '11 at 19:12
  • What is the shared memory usage of your program? Process Explorer will tell you. – Mike Jul 30 '11 at 19:17
  • I'm having similar problem with opengl application. Page faults really affect performance of 3d rendering. Except that my problem is worse, as it happens during normal execution. When executed through visual studio rendering is much smoother. – AareP Jan 17 '12 at 16:10

1 Answers1

4

Page faults are normal. It's part of the process of allocating memory. This is nothing to worry about.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • True but he is getting 100K page faults per second in the debugger and a much smaller rate when not in the debugger. What explains that? – Mike Jul 30 '11 at 19:20
  • the debugger is going to provoke page faults – David Heffernan Jul 30 '11 at 19:28
  • Yes, it seems so. But why? It makes sense in debug builds, but I would've thought at least in release builds there would be somewhat fewer. – Darcara Jul 30 '11 at 19:54
  • I've never giving much thought to how the debugger works. It makes sense that the debugger would want a page fault to occur on pages that contains variables it wants to watch. – Mike Jul 30 '11 at 19:56
  • 1
    @Darcara, the debugger still works in release builds but not as well because of the optimized code. – Mike Jul 30 '11 at 20:00