Found the problem. There is missing a buf_unref in display_frame in the first sample, this was corrected later in the discussion.