[Image Removed]
hi,ios预热pso后,内存增长近百M,像是PSO内存没有卸载,项目里面 rhi.Metal.CacheShaderPipelines 配置的是0
发现 FMetalCompiledShaderCache 有个成员 TMap<FMetalCompiledShaderKey, mtlpp::Function> Cache,会缓存底层的 mtlpp::Function,这里是否要在 TMetalBaseShader 销毁的地方手动释放一下,比如下面这样
template<typename BaseResourceType, int32 ShaderType>
void TMetalBaseShader<BaseResourceType, ShaderType>::Destroy()
{
@autoreleasepool{
[GlslCodeNSString release];
//Add Begin
Function = nil;
Library = nil;
uint32 FunctionConstantHash = ConstantValueHash;
FMetalCompiledShaderKey Key(SourceLen, SourceCRC, FunctionConstantHash);
GetMetalCompiledShaderCache().Remove(Key);
//Add End
}
}
struct FMetalCompiledShaderCache
{
bool Remove(FMetalCompiledShaderKey Key)
{
bool bReleased = false;
@autoreleasepool{
FRWScopeLock ScopedLock(Lock, SLT_Write);
if (Cache.FindRef(Key) != nil)
{
mtlpp::Function::Type FuncPtr = Cache.FindRef(Key).GetPtr();
LibCache.Remove(FuncPtr);
Cache.Remove(Key);
bReleased = true;
}
}
return bReleased;
}
}
[Attachment Removed]