Skip to content

Commit a6b963b

Browse files
authored
Fix potential memory leak on Apple platforms (#1130)
In XR.mm when the call to `CVMetalTextureCacheCreateTextureFromImage` fails, the texture reference is not being released. In the Xcode AR example the texture reference is explicitly released when `CVMetalTextureCacheCreateTextureFromImage` fails, so we should probably do the same thing to make sure no memory is being leaked.
1 parent 03f314e commit a6b963b

File tree

1 file changed

+1
-0
lines changed
  • Dependencies/xr/Source/ARKit

1 file changed

+1
-0
lines changed

Dependencies/xr/Source/ARKit/XR.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ - (CVMetalTextureRef)getCameraTexture:(CVPixelBufferRef)pixelBuffer plane:(int)p
334334
// Create a texture from the corresponding plane.
335335
auto status = CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, textureCache, pixelBuffer, nil, pixelFormat, planeWidth, planeHeight, planeIndex, &texture);
336336
if (status != kCVReturnSuccess) {
337+
CVBufferRelease(texture);
337338
return nil;
338339
}
339340

0 commit comments

Comments
 (0)