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

  • Home
  • SEARCH
  • 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

I'm using MySQL API's function mysql_real_escape_string() Based on the documentation, it escapes the following
I am using http://code.google.com/apis/maps/documentation/geocoding/ api from google to get geolocation based on address. I
I have a web-based documentation searching/viewing system that I'm developing for a client. Part
Based on the documentation (MSDN: link ), it is clear that one should use
The Django documentation gives examples for using annotate() to produce aggregate results based on
I don't understand the documentation at php.net . It appears they are using the
I have an assembly containing very thorough XML-based documentation, which is used through Sandcastle
Based on a few posts I've read concerning version control, it seems people think
Based on this question it appears that the default template for CheckStyle will allow
Based on documentation and articles it is recommended to call Abort() on a client

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.