This text was edited after extended investigation and double checks.
I'm developing an enterprise (not game) app based on Metal API in Xamarin, and I have critical issue: Metal textures aren't releasing it's memory after dispose, what is leading to extensive memory leaks and app crashes.
class SomeClass
{
public void CreateTexture()
{
var metalTexture = device.CreateTexture(textureDescriptor);
metalTexture.Dispose();
}
}
Above you can see a simplified sample, which are demonstrates the issue. A texture's memory doesn't release after Dispose() call, even when texture is a local variable.
Can anybody explain what is going on, and how to release texture's memory?
It looks like Metal Kit support in Xamarin is totally broken and useless because of this issue. And I'm deeply shocked: WTF is going on?! How is it possible for Xamarin team to make initially broken feature and don't fix the issue for years? What are you doing there, guys? Xamarin forums is totally dead. Currently, this proudly called "Visual studio for Mac", but what's the point? Damn code snippets are still buggy – have to delete auto-inserted parenthesis to fix the cursor.
P.S.
Here is the repo with the project demonstrating the problem:
https://github.com/kav-git/Xamarin-Metal-Issue
- Memory usage is logged into Output window of IDE during debug.
- Press
Add texture
button to add new 64Mb texture to collection. - Press
Dispose textures
button to purge all textures. No memory will be released. - Press
Release pixelData
button to ensure GC is OK when you have deal with non-texture objects. - Use
GC.Collect()
button just for fun.