proc_pid_clear_refs(5)

๐Ÿ’– proc_pid_clear_refs(5) โ€” the girlies' guide ๐Ÿ’–

ok so this is a page from the File Formats Manual, bestie, and it's all about one very specific little file. let's get into it ๐Ÿซถ


โœจ NAME โœจ

/proc/pid/clear_refs โ€” reset the PG_Referenced and ACCESSED/YOUNG bits


๐ŸŒธ DESCRIPTION ๐ŸŒธ

/proc/pid/clear_refs (since Linux 2.6.22)

okay so first thing, the vibe check: this is a write-only file. you can't read it, no ma'am. and it's writable only by the owner of the process โ€” so like, it's giving exclusive, invite-only energy. ๐Ÿ’…

here's what you can write to it:

  • 1 (since Linux 2.6.22) โ€” reset the PG_Referenced and ACCESSED/YOUNG bits for all the pages associated with the process. ๐Ÿซถ
๐Ÿšจ lore drop: before Linux 2.6.32, writing any nonzero value to this file had this exact effect. so like, back then, 7 and 1 were the same thing, no cap.
  • 2 (since Linux 2.6.32) โ€” reset the PG_Referenced and ACCESSED/YOUNG bits for all the anonymous pages associated with the process.
  • 3 (since Linux 2.6.32) โ€” reset the PG_Referenced and ACCESSED/YOUNG bits for all the file-mapped pages associated with the process.

๐Ÿฆ‹ why would you even do that tho ๐Ÿฆ‹

clearing the PG_Referenced and ACCESSED/YOUNG bits gives you a method to measure approximately how much memory a process is using. it's a whole little ritual and honestly it slays:

  1. first, you go inspect the values in the "Referenced" fields for the VMAs shown in /proc/pid/smaps โ€” that gives you an idea of the memory footprint of the process. โœจ
  2. then you clear the PG_Referenced and ACCESSED/YOUNG bits, and after some measured time interval, you go inspect those "Referenced" fields again โ€” that gives you an idea of the change in memory footprint of the process during the measured interval. ๐Ÿ’ซ

and if you're only interested in inspecting the selected mapping types? then you can use the value 2 or 3 instead of 1. periodt. ๐ŸŽ€


๐Ÿ‘‘ further values (yes, there's more) ๐Ÿ‘‘

  • 4 (since Linux 3.11) โ€” clear the soft-dirty bit for all the pages associated with the process. this one is used, in conjunction with /proc/pid/pagemap, by the check-point restore system to discover which pages of a process have been dirtied since the file /proc/pid/clear_refs was written to. iykyk ๐Ÿงš
  • 5 (since Linux 4.0) โ€” reset the peak resident set size (the "high water mark", iconic name tbh) to the process's current resident set size value. ๐Ÿ“‰

๐Ÿ’€ the fine print (important, bestie, don't skip) ๐Ÿ’€

writing any value to /proc/pid/clear_refs other than those listed above has no effect. literally nothing happens. the file is not gagged, it's just unbothered. ๐Ÿ™ˆ
alsoooo: the /proc/pid/clear_refs file is present only if the CONFIG_PROC_PAGE_MONITOR kernel configuration option is enabled. no config option, no file, no ~vibes~. ๐Ÿ‘‘

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • proc(5) โ€” the mothership, the main character, go read her ๐Ÿซถ

written up in Linux man-pages 6.20, dated 2026-02-08, for all my proc_pid_clear_refs(5) girlies โ€” stay hydrated, clear your bits, and remember: write-only means write-only ๐Ÿ’œโœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: GPL-3.0-or-later
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms