Skip to content

Conversation

@martindevans
Copy link
Contributor

Following this example for point clouds led to a resource leak.

As documented in the section on casting:

// As creates a new object, both need to be disposed

Fixed this.

@sysrsbuild
Copy link
Contributor

Can one of the admins verify this patch?

@Nir-Az Nir-Az requested a review from Copilot August 3, 2025 07:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a resource leak in the C# Point Cloud documentation example by properly disposing of intermediate frame objects created during point cloud processing.

  • Separates the pc.Process(depth) call from the As<Points>() cast to ensure both objects are properly disposed
  • Adds proper using statement for the intermediate frame object to prevent resource leaks
Comments suppressed due to low confidence (1)

wrappers/csharp/Documentation/cookbook.md:284

  • [nitpick] The variable name 'frame' is too generic. Consider using a more descriptive name like 'processedFrame' or 'pointCloudFrame' to clarify that this is the result of point cloud processing.
using (var frame = pc.Process(depth))

using (var frames = pipe.WaitForFrames())
using (var depth = frames.DepthFrame)
using (var points = pc.Process(depth).As<Points>())
using (var frame = pc.Process(depth))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR !
I suggest to rename frame to pc_frame
Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Renamed frame to pc_frame (review feedback)
@Nir-Az Nir-Az merged commit 8c3bcb9 into realsenseai:development Aug 13, 2025
@martindevans martindevans deleted the fix-docs-leak branch August 13, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants