You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a memory leak (or unbounded memory growth) when using and appsink element and mapping a new sample's buffer but not copying the data out. This can be reproduced using the appsink example, and changing to the videotestsrc, as follows :
funccreatePipeline() (*gst.Pipeline, error) {
gst.Init(nil)
pipeline, err:=gst.NewPipeline("")
iferr!=nil {
returnnil, err
}
src, err:=gst.NewElement("videotestsrc")
iferr!=nil {
returnnil, err
}
// Should this actually be a *gst.Element that produces an Appsink interface like the// rust examples?sink, err:=app.NewAppSink()
iferr!=nil {
returnnil, err
}
pipeline.AddMany(src, sink.Element)
src.Link(sink.Element)
// Tell the appsink what format we want. It will then be the audiotestsrc's job to// provide the format we request.// This can be set after linking the two objects, because format negotiation between// both elements will happen during pre-rolling of the pipeline.sink.SetCaps(gst.NewCapsFromString(
"video/x-raw",
))
// Getting data out of the appsink is done by setting callbacks on it.// The appsink will then call those handlers, as soon as data is available.sink.SetCallbacks(&app.SinkCallbacks{
// Add a "new-sample" callbackNewSampleFunc: func(sink*app.Sink) gst.FlowReturn {
// Pull the sample that triggered this callbacksample:=sink.PullSample()
ifsample==nil {
returngst.FlowEOS
}
// Retrieve the buffer from the samplebuffer:=sample.GetBuffer()
ifbuffer==nil {
returngst.FlowError
}
// At this point, buffer is only a reference to an existing memory region somewhere.// When we want to access its content, we have to map it while requesting the required// mode of access (read, read/write).//// We also know what format to expect because we set it with the caps. So we convert// the map directly to signed 16-bit little-endian integers.buffer.Map(gst.MapRead)
deferbuffer.Unmap()
returngst.FlowOK
},
})
returnpipeline, nil
}
The only solution I could come up with using appsink was:
buffer.Map(gst.MapRead).Bytes()
which makes a copy.
However, if you use an identity element and use it's handoff signal then the no copy access works. There must be something special with appsink that breaks this.
There seems to be a memory leak (or unbounded memory growth) when using and
appsink
element and mapping a new sample's buffer but not copying the data out. This can be reproduced using the appsink example, and changing to thevideotestsrc
, as follows :The main change from this
to this
By not calling
AsInt16LESlice()
(or any of the other methods that make a copy of the data, e.g.Bytes()
), the memory will grow.I'm trying to get zero-copy access to the underlying data, as follows:
The text was updated successfully, but these errors were encountered: