Comments (7)
Ah interesting, I was looking at the code for a while and wondered where something like this could occur.
The created C buffers are unrefed here and the wrapBuffer function you mention only performs a golang allocation.
The NewBufferFromBytes function seems to correctly unref all created C objects.
Ah but I see a lonely Ref()
call in PushBuffer
(aka no unref), that may be the source of your issue.
I even think that there shouldn't be a Ref()
call in the first place, since gst_app_src_push_buffer takes ownership of the buffer.
@onthegit could you try it out and post your feedback, or provide me with a minimal setup that I can run and profile?
from go-gst.
@tinyzimmer what do you think?
from go-gst.
@tinyzimmer what do you think?
This isn't the first memory leak fought on those methods. The last one dates back to gstreamer 1.18.
I'll have to look more closely to see but last I recall that buffer is just populated with a memset from the original.
Debugging memory leaks in CGO is a particular pain. At the time a heavily tuned valgrind helped me track it down.
from go-gst.
Hello, thanks for your replies,
I tried replacing NewBufferFromBytes with
p.src.PushBuffer(gst.NewBufferFull(gst.MemoryFlagReadOnly, cp, int64(len(cp)), 0, int64(len(cp)), func() { fmt.Println("closed") }))
and the memory leak is even bigger. The function does print when the buffer is closed
from go-gst.
@RSWilli I tried removing Ref() and the memory still kept growing.
from go-gst.
It appears the there is memory leak in mp4mux element. Valgrind shows that there are a lot of allocations in gstreamer isomp4 library. The mp4mux element was set like this:
if err = mux.SetProperty("faststart", true); err != nil {
return nil, errors.New("could not set property: faststart " + err.Error())
}
if err = mux.SetProperty("fragment-duration", uint(60)); err != nil {
return nil, errors.New("could not set property: fragment-duration " + err.Error())
}
mux.SetArg("fragment-mode", "first-moov-then-finalise")
Once they were removed, the leak was gone. I am still testing whether it will leak again but so far have not seen major increases in memory usage. Will test further.
So this might be a problem with the mp4mux element, and maybe someone with permissions at gstreamer repo can report the issue.
Worth mentioning is that there was no leak (from my short testing) when the pipeline elements (except src element) were replaced with fakesink
from go-gst.
You could talk to the gstreamer devs on the gstreamer IRC channel.
maybe someone with permissions at gstreamer repo can report the issue
You can create an account by yourself and get verified to report the issue, though.
from go-gst.
Related Issues (20)
- proxysink/proxysrc usage HOT 1
- Small memory leak over time HOT 16
- Figure out what's wrong with windows mingw 12 HOT 5
- Handling SIGSEGV when in docker container HOT 9
- Look into CgoSymbolizers
- Glib string property issue HOT 2
- SEGFAULT using glib.Value HOT 13
- Create documentation on how to properly unref a pipeline when you're done with it. HOT 8
- Investigate windows build issues HOT 3
- How to set GstElement *(or *gst.Element) to a Property? HOT 9
- video display support on MacOS HOT 9
- could not determine kind of name for C.gst_element_factory_make_with_properties HOT 5
- Audio problem originating from package name for Example HOT 6
- Not an issue but a request for more examples HOT 4
- possible misuse of unsafe.Pointer in gasyncresult.go HOT 5
- Handle up- and downcasting safely HOT 11
- unmarshaling nvdsbatchmeta HOT 48
- warnings on macos HOT 1
- Add support for retrieving tracers
- Docs are suggesting Unrefs that lead to segfaults HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-gst.