What is Page FAULTS?

C

Crirus

I made a simple test... loaded an image from file and draw it on a form
In mouse move, I just refresh the form.... that cause 1 000 000 page faults
(as task manager shows) in less than a minute.. what is that?
 
M

Milan Todorovic

Crirus,
Windows uses Virtual Memory management system, that effectively allows the
process in run state to use all the available RAM. The other processes are
put in wait status, while your process is running, and if your process is
requiring more memory then the system has, it stores the status information
of the waiting process on the HDD and allows your process to use their space
in RAM. This swap is called a page fault.
Now, OS gives each process a preset time interval of running (to achieve
multitasking, usually several CPU clock ticks), so after that time quant for
your process is up, the OS put you process in wait status and activates the
waiting processes. The it has to do page faults to reload their status info
into RAM.

The large number of page faults tells me the following:
1. You are rendering HUGE picture.
2. You wrote the app inefficiently so the memory management is struggling to
keep up with memory expansion on each refresh.
3. Combination of the 1 and 2

I hope this explains and good luck
Milan Todorovic

PS. For further understanding of OS memory management see any OS theory book
(e.g. Tannenbaum's Modern Operating System)
 
C

Crirus

Well... all I did is the following.. for testing pourpose

(the image is a fullscreen size jpg)

Private myimg As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
myimg = Bitmap.FromFile("1.jpg")
End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.DrawImage(myimg, 0, 0, myimg.Width, myimg.Height)
End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Me.Refresh()
End Sub


How can I handle a full screen image other way to display in a maximized
form?!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top