Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5967759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:59:25+00:00 2026-05-22T19:59:25+00:00

Based on documentation and xnu source I’ve read, I understand that Mac OS X

  • 0

Based on documentation and xnu source I’ve read, I understand that Mac OS X caches file I/O using the Unified Buffer Cache (UBC). The UBC grows as big as it can based on available RAM, but UBC pages are some of the first to be sacrificed when memory gets tighter.

In my driver, I deal with various on-disk metadata. I’d like to be able to use the UBC or a similar mechanism to keep MRU caches of this data around to speed things up, yet give the kernel the ability to take back that memory whenever it needs to. The metadata however doesn’t represent file data, and thus doesn’t fall directly into the UBC’s domain. Is there a lower-level mechanism I can use, or can I somehow use only the part of the UBC that deals with the buffers themselves?

I’m currently hunting around the HFS+ source code to try and figure out whether and how it caches filesystem metadata, albeit without much success.

The main alternative is of course to reserve a specific memory region for caches and do my own LRU culling. I can choose a fixed cache size or use some kind of heuristic, but it’s always going to use too little memory when RAM is abundant and too much when it isn’t.

Update:

After searching some more, I’ve found that instances of IOBufferMemoryDescriptor may be created with the kIOMemoryPurgeable option. This lets you call IOMemoryDescriptor::setPurgeable() on it to mark the memory “fair game” for discarding. I’ll try it and update the question with results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:59:26+00:00Added an answer on May 22, 2026 at 7:59 pm

    You are correct. Set kIOMemoryPurgeable as one of the options when you request the memory. It starts off as nonvolatile, and may be paged out, but won’t be discarded.

    When you want to let the OS discard it, call setPurgeable(kIOMemoryPurgeableVolatile, &oldState ); and the OS will discard it if necessary, rather than paging it to disk.

    When you want to access the memory, you must call setPurgeable(kIOMemoryPurgeableKeepCurrent, &oldState ); and check if(oldState != kIOMemoryPurgeableEmpty) which will be true if the memory is still available, and false if it has been discarded.

    I would be interested to hear if you ran into any catches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on the documentation for PyUnit , I would expect the following code to
Is the parsing order for Django templates specified somewhere in the Django documentation? Based
I want to codesign an .exe file using an API rather than running signtool.exe.
I am considering to utilize Expression-Based Access Control from Spring Security 3.0. The documentation
The Documentation on ByteArrayInputStream says : java.io.ByteArrayInputStream.ByteArrayInputStream(byte[] buf) Creates a ByteArrayInputStream so that it
What is the difference between void QSqlQuery::clear () and void QSqlQuery::finish () Based on
I am using the declarative authorization gem for permissions in a rails project and
That title probably doesn't sound right, but forgive me, I'm learning Rails for the
Can Eclipse browse imported packages and built-in classes or should I just look at
I have a basic singleton class, similar to the one shown in the PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.