Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Metal renderer memory leak #3909

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions pjmedia/src/pjmedia-codec/vid_toolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -554,17 +554,20 @@ static OSStatus create_encoder(vtool_codec_data *vtool_data)

ret = VTSessionCopySupportedPropertyDictionary(vtool_data->enc,
&supported_prop);
if (ret == noErr &&
CFDictionaryContainsKey(supported_prop,
if (ret == noErr) {
if (CFDictionaryContainsKey(supported_prop,
kVTCompressionPropertyKey_MaxH264SliceBytes))
{
/* kVTCompressionPropertyKey_MaxH264SliceBytes is not yet supported
* by Apple. We leave it here for possible future enhancements.
SET_PROPERTY(vtool_data->enc,
kVTCompressionPropertyKey_MaxH264SliceBytes,
// param->enc_mtu - NAL_HEADER_ADD_0X30BYTES
(__bridge CFTypeRef)@(param->enc_mtu - 50));
*/
{
/* kVTCompressionPropertyKey_MaxH264SliceBytes is not yet supported
* by Apple. We leave it here for possible future enhancements.
SET_PROPERTY(vtool_data->enc,
kVTCompressionPropertyKey_MaxH264SliceBytes,
// param->enc_mtu - NAL_HEADER_ADD_0X30BYTES
(__bridge CFTypeRef)@(param->enc_mtu - 50));
*/
}

CFRelease(supported_prop);
}

VTCompressionSessionPrepareToEncodeFrames(vtool_data->enc);
Expand Down
7 changes: 7 additions & 0 deletions pjmedia/src/pjmedia-videodev/metal_dev.m
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ - (nonnull instancetype)initWithMetalKitView:(nonnull MTKView *)mtkView
textureCoordBuffer = [device newBufferWithBytes:textureCoordinates
length:sizeof(textureCoordinates)
options:MTLResourceStorageModeShared];

[pQuadPipelineStateDescriptor release];
[fragmentProgram release];
[vertexProgram release];
[shaderLibrary release];
}

return self;
Expand Down Expand Up @@ -509,6 +514,8 @@ - (void)update_image
[commandBuffer presentDrawable:drawable];
[commandBuffer commit];

[texture release];

stream->is_rendering = PJ_FALSE;
}

Expand Down
Loading