How to get the remaining memory on gpu of macOS programmatically?

Hi, I want to know the gpu device available memory by code, so that I could calculate the size of buffer and texture I will create using Metal. I only find the MTLDevice's property currentAllocatedSize that can show the allocated memory for this process.

Hi, please take a look at https://developer.apple.com/documentation/metal/mtldevice/2369280-recommendedmaxworkingsetsize?language=objc. Apart from that could you also expand on the usage a little, specifically, are you trying to get to a dynamic value or a static one (say to scale your allocations at initialization)

Thanks for your reply. In my suituation, I'm trying to get to a dynamic value at runtime.

For example, I have a certain pipeline for 360x640 input image and I create all resources the pipeline needed in one thread . Then another 540x960 input image is requested in another thread, I want to know whether I should create a complex pipeline with heavy gpu memory usage or create a simple pipeline with light gpu memory usage due to the existing memory alloaction of previous 360x640 pipeline. I need to know the remaining memory on gpu each time I want to create a knew pipeline (total memory size in bytes could be considered as [device recommendedMaxWorkingSetSize]) .

How to get the remaining memory on gpu of macOS programmatically?
 
 
Q