Sublime Forum

Page Faults

#1

Tried out Sublime Text 2 Win 64 Bit (2139)
While using it i felt the system behaved a little more clogy than usual. After checking the task manager i saw that ST 2 had over 2 million page faults. (http://en.wikipedia.org/wiki/Page_fault) :geek:
Finding that quite strange i restarted ST2 and the number of page faults was quite reasonable. The instant i started scrolling a simple plain text file (also just 1 tab), the number skyrocketed. I can’t think of any reason this should be normal, the only program that i got running that get close (or above) to that number is my anti-virus program and Steam.

Also, it does not only apply to scrolling. Just letting the program idle in the foreground has the same effect, but not so profound.

tl;dr
possible page fault leak in win 64 bit version of Sublime Text 2.

edit:
also happens with the 32-bit version (2139)

0 Likes

#2

Do you have any plugins installed?

0 Likes

#3

No, not that i know about. It was a fresh installation, the same day.
Also, i noticed it is also happening on my laptop (win 7 enterprise 32-bit, version 2139). I tried reverting it, same results.

0 Likes

#4

Experiment name: “ALL YOUR PAGE FAULTS ARE BELONG TO SUBLIME TEXT 2”
requirement: Windows 7, Sublime Text 2 (2139)

How to show “Page Faults” in task managers processes tab:
a. Start task manager.
b. Got to processes tab.
c. In the menu bar, “view” -> “select columns…”.
d. Enable the “Page Faults” option.
e. Done.

Procedure:

  1. Start task manager.
  2. Start Sublime Text 2.
  3. Observe the numbers of “Page Faults” for Sublime Text 2.
  4. Do something in Sublime Text 2. Example: write, select and/or delete some text.
  5. Observe again.
  6. Do point 4-5 over some times.
  7. Tell about the result
0 Likes

#5

Page Faults in and of themselves aren’t a helpful metric, and don’t generally indicate bugs or memory leaks. I’d only be concerned about a large value for Private Bytes, or sluggish user-perceived responsiveness.

0 Likes

#6

Why i said i could be a possible leak, i don’t know if this behavior is intentional or not. Besides it is quite a rampant increase for using basic functions of the software, i found it strange.

0 Likes

#7

In general, any use of large temporary memory allocations will result in page faults. Large memory mallocs / frees will result in 1:1 calls to VitualAlloc/VirtualFree, whereas small memory allocations are coalesced. Memory returned from VirtualAlloc will cause a page fault whenever each page in touched for the first time: initially each page memory is simply added to the virtual address space, but has no physical memory backing it until the page fault is triggered.

Although I haven’t looked into it in detail, I’d guess a source of the larger number of page faults you see in Sublime Text comes from the drawing code. Whenever a window is redrawn, a temporary buffer the size of the window is allocated (for double-buffered drawing), which due to its size will usually be allocated via VirtualAlloc (as opposed to using memory in the unallocated portion of the heap), and so will trigger page faults when accessed. The flip side of this is that you get flicker free drawing on Windows, which is not typical of the platform.

0 Likes

#8

+1.

Similar (or higher) number Page Faults can be observed in other render-heavy applications: Opera (doing pretty much anything), Thunderbird (list scrolling).

0 Likes