Metal texture doesn't disposed

SukiSuki RUMember
edited August 2017 in Xamarin.iOS

Hi, I'm developing an enterprise (not game) app based on Metal API, 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.

I've made some investigation and achieved strange results, which I can't explain.

Case 1:

class SomeClass : IDisposable
{
    private IMTLTexture _metalTexture;

    public void CreateTexture()
    {
        _metalTexture = device.CreateTexture(textureDescriptor);
    }

    public void Dispose()
    {
        _metalTexture.Dispose();
        _metalTexture = null;
    }
}

Case 2:

class SomeClass
{
    public void CreateTexture()
    {
        var metalTexture = device.CreateTexture(textureDescriptor);
        metalTexture.Dispose();
    }
}

Above you can see two simplified cases, which are demonstrates the issue.
The problem is in case 1. A texture's memory doesn't release after Dispose() call, when a created texture is stored in a class field. At the same time there is no problem, when texture's reference is stored in local variable.

Can anybody explain what is going on, and how to release texture's memory?

P.S.
It's not a reference count problem (there are no any other references to texture).

Tagged:

Answers

  • InghamIngham FRMember
    edited July 2018

    Is this problem solved ? My textures & buffers don't really deallocate and I can't figure out why !
    I've also tried to manually call the ObjC "dealloc" on the Handle of the buffer but it's still there !

    A simple loop that create and dispose metal buffers crashes after creating ~3.6 GB of buffers (even if I correctly disposed all of them)

Sign In or Register to comment.