0

I am running object detection on buffers from gstreamer and am utilizing gst_buffer_extract_dup to create an image array from a Gstreamer buffer. Here is a code snip:

gstbuffer = gstsample.get_buffer()
caps_format = gstsample.get_caps().get_structure(0)  # Gst.Structure
frmt_str = caps_format.get_value('format') 
video_format = GstVideo.VideoFormat.from_string(frmt_str)
            
p, q = caps_format.get_value('width'), caps_format.get_value('height')
buf = gstbuffer.extract_dup(0, gstbuffer.get_size())
          
array = np.ndarray(shape=(q, p, 3), \
buffer = buf, \
dtype='uint8')
        
svg = self.user_function(gstbuffer, array, self.src_size, self.get_box())

I have discovered a substantial memory leak causing the program to crash within 10 minutes and have identified extract_dup as the likely cause as the GStreamer documentation says it needs to be freed with g_free. The (potential) problem is that I cannot figure out the syntax for doing this. trying GLib.free(buf) results in the error "GLib.free(buf) ValueError: Pointer arguments are restricted to integers, capsules, and None. See: https://bugzilla.gnome.org/show_bug.cgi?id=683599 " How would I free this memory? Furthermore, how can I confirm that this memory isn't being freed and is the cause of my leak?

zclements
  • 1
  • 1

0 Answers0