Bug 12846 - CFRelease() method is not called at CVPixelBuffer.Dispose()
Summary: CFRelease() method is not called at CVPixelBuffer.Dispose()
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.9.1.x
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-06-24 08:25 UTC by David Ávila Membrives
Modified: 2013-07-02 05:55 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description David Ávila Membrives 2013-06-24 08:25:52 UTC
In the following sample, the internal buffer of pixelBuffer variable is never release (in Objective C, you must to call CFRelease method):

CVPixelBuffer pixelBuffer = this.videoOutput.CopyPixelBuffer(outputItemTime, ref outTimeToDisplay);

// lock pixelBuffer
// use pixelBuffer
// unlock pixelBuffer

pixelBuffer.Dispose(); // <-- this buffer is never released



To avoid this, you must manually import the CFRelease method

[DllImport (MonoTouch.Constants.CoreFoundationLibrary, CharSet=CharSet.Unicode)]
internal extern static IntPtr CFRelease (IntPtr obj);

and later, call this method:

CFRelease(pixelBuffer.Handle);
Comment 1 Marek Safar 2013-07-01 12:56:03 UTC
Why do you think it's not release. It should be released from Dispose method or CVBuffer finalizer
Comment 2 Rolf Bjarne Kvinge [MSFT] 2013-07-01 17:37:13 UTC
It's released in Dispose, but it's also retained in the ctor. And since the native CopyPixelBuffer method (copyPixelBufferForItemTime:itemTimeForDisplay:) returns a retained object, you end up with two retains and one release.
Comment 3 Marek Safar 2013-07-02 05:55:14 UTC
Fixed