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 3237942
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:47:49+00:00 2026-05-17T17:47:49+00:00

does anyone know how to get the free(!) vram on os x? I know

  • 0

does anyone know how to get the free(!) vram on os x?

I know that you can query for a registry entry:

typeCode = IORegistryEntrySearchCFProperty(dspPort,kIOServicePlane,CFSTR(kIOFBMemorySizeKey),
                                           kCFAllocatorDefault,
                                           kIORegistryIterateRecursively | kIORegistryIterateParents);

but this will return ALL vram, not the free vram. Under windows you can query for free VRAM using directshow

mDDrawResult = DirectDrawCreate(NULL, &mDDraw, NULL);
mDDrawResult = mDDraw->QueryInterface(IID_IDirectDraw2, (LPVOID *)&mDDraw2);
DDSCAPS ddscaps;
DWORD   totalmem, freemem;
ddscaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
mDDrawResult = mDDraw2->GetAvailableVidMem(&ddscaps, &totalmem, &freemem);

Ugly, but it works. Anyone knows the osx way?

Best
Wendy

  • 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-17T17:47:50+00:00Added an answer on May 17, 2026 at 5:47 pm

    answering myself so others may use this:


    #include <IOKit/graphics/IOGraphicsLib.h>
    size_t currentFreeVRAM()
    {
    
        kern_return_t krc;  
        mach_port_t masterPort;
        krc = IOMasterPort(bootstrap_port, &masterPort);
        if (krc == KERN_SUCCESS) 
        {
            CFMutableDictionaryRef pattern = IOServiceMatching(kIOAcceleratorClassName);
            //CFShow(pattern);
    
            io_iterator_t deviceIterator;
            krc = IOServiceGetMatchingServices(masterPort, pattern, &deviceIterator);
            if (krc == KERN_SUCCESS) 
            {
                io_object_t object;
                while ((object = IOIteratorNext(deviceIterator))) 
                {
                    CFMutableDictionaryRef properties = NULL;
                    krc = IORegistryEntryCreateCFProperties(object, &properties, kCFAllocatorDefault, (IOOptionBits)0);
                    if (krc == KERN_SUCCESS) 
                    {
                        CFMutableDictionaryRef perf_properties = (CFMutableDictionaryRef) CFDictionaryGetValue( properties, CFSTR("PerformanceStatistics") );
                        //CFShow(perf_properties);
    
                        // look for a number of keys (this is mostly reverse engineering and best-guess effort)
                        const void* free_vram_number = CFDictionaryGetValue(perf_properties, CFSTR("vramFreeBytes"));
                        if (free_vram_number) 
                        {
                            ssize_t vramFreeBytes;
                            CFNumberGetValue( (CFNumberRef) free_vram_number, kCFNumberSInt64Type, &vramFreeBytes);
                            return vramFreeBytes;
                        }
                    }
                    if (properties) CFRelease(properties);
                    IOObjectRelease(object);
                }           
                IOObjectRelease(deviceIterator);
            }
        }
        return 0; // when we come here, this is a fail 
    }
    

    • i am somewhat surprised that this query takes almost 3 msec ..
    • be aware that there may be more than one accelerator on your system ( eg. macbook )
      so be sure you select the proper one for the query
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of a free tool that I can use to get website
As the question above, does anyone know where i can get free flash tutorials
Does anyone know where I can get Royalty Free images ( Preferably High Quality
Does anyone know how I can get rid of the following assembler warning? Code
Does anyone know how I can get a format string to use bankers rounding
Does anyone know of a way to get the free disk space of a
Does anyone know how I can get a thumbnail/avatar of a facebook user using
Does anyone know of a free-licence PHP code that would convert numbers to words
Does anyone know how to get IntelliSense to work reliably when working in C/C++
Does anyone know how to get the MS Office 2007 .NET C# Interop libraries

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.