How to programmatically force hard page faults?

From: ohaya (ohaya_at_cox.net)
Date: 09/28/04


Date: Mon, 27 Sep 2004 20:55:07 -0400

Hi,

I hope that this is an appropriate newsgroup for my question. I looked
around, but this seems to be the closest.

I have a somewhat unusual request:

I'm trying to write a program that will force hard page faults over a
sustained period of time.

The reason that I'm trying to do this, is that I'm doing some testing of
a new system, and am trying to determine how it reacts to hard page
faults under certain circumstances.

I've put together a small C++ program that basically loops and does
'new', e.g., something like:

  for (i=0;i<32000;i++)
  {
  char * p = new char[57329];
  x = p[0];
  }

The above code does trigger lots of page faults, but when I monitor Page
Reads/sec with Performance Monitor, it is showing 0, i.e., it looks like
all the faults are soft page faults.

Sorry if this is a somewhat strange request, and thanks in advance!

jim