Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Memory leak #160

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions container/flv/muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type FLVWriter struct {
buf []byte
closed chan struct{}
ctx *os.File
closedWriter bool
}

func NewFLVWriter(app, title, url string, ctx *os.File) *FLVWriter {
Expand Down Expand Up @@ -131,6 +132,10 @@ func (writer *FLVWriter) Wait() {
}

func (writer *FLVWriter) Close(error) {
if writer.closedWriter {
return
}
writer.closedWriter = true
writer.ctx.Close()
close(writer.closed)
}
Expand Down
2 changes: 1 addition & 1 deletion protocol/rtmp/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (s *Stream) CheckAlive() (n int) {
v := val.(*PackWriterCloser)
if v.w != nil {
//Alive from RWBaser, check last frame now - timestamp, if > timeout then Remove it
if !v.w.Alive() && s.isStart {
if !v.w.Alive() {
log.Infof("write timeout remove")
s.ws.Delete(key)
v.w.Close(fmt.Errorf("write timeout"))
Expand Down