Memory leak on releasing MTLCommandBuffer

Hi! I'm trying to execute some kernels multiply times, but encoder creation, execution and deallocation called from different places, so i can't just put it into @autoreleasepool. Then i try to release command buffer manually nothing happens. Sample:
Code Block objective-c
for (int32_t i = 0; i<100000; ++i)
{
_commandBuffer = [_commandQueue commandBuffer];
    _encoder = [_commandBuffer computeCommandEncoder];
   ... setup encoder and execute
[_encoder release];
[_commandBuffer release];
//encoder successfully released, but buffer still present and retain count = 1
_encoder = nil;
    _commandBuffer = nil;
}

In result of this code program just eat all available memory.

How can i fix this issue?


In your simplified example, did adding an autorelease pool fixed it? Just to know if it's the culprit.
Yes, @autorelease in "for" will fix the issue. But, unfortunately i can't use it in real app:(
Memory leak on releasing MTLCommandBuffer
 
 
Q