I notice some metal-cpp classes have static funtion like
static URL* fileURLWithPath(const class String* pPath);
static class ComputePassDescriptor* computePassDescriptor();
static class AccelerationStructurePassDescriptor* accelerationStructurePassDescriptor();
which return a new object. these classes also provide 'alloc' and 'init' function to create object by default. for object created by 'alloc' and 'init', I use something like NS::Shaderd_Ptr or call release directly to free memory. Because 'alloc' and 'init' not explicit call on these static function. I wonder how to correctly free object created by these static function? did they managed by autorelease pool?
From the Getting started with Metal-cpp page:
Metal-cpp follows the object allocation policies of Cocoa and Cocoa Touch. Understanding those rules is especially important when using metal-cpp because C++ objects aren’t eligible for automatic reference counting (ARC). For more information, refer to the Read Me file in the metal-cpp download.
The README.md included with the metal-cpp download includes an extended discussion of memory management considerations. I suggest starting with that.
Also, there is a discussion of memory management for the metal-cpp header library in this WWDC talk:
WWDC22 - Program Metal in C++ with metal-cpp
These are older articles in the documentation archives, but for additional background they may be useful: