Merge pull request #253 from kuabhish/fix_memory_leak_scenario

[opt] rtmp: reduce memory consumption when dividing chunk
pull/256/head
yoko 2 years ago committed by GitHub
commit 2fd1925da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,9 +11,10 @@ package rtmp
// 将message切割成chunk // 将message切割成chunk
import ( import (
"net"
"github.com/q191201771/lal/pkg/base" "github.com/q191201771/lal/pkg/base"
"github.com/q191201771/naza/pkg/bele" "github.com/q191201771/naza/pkg/bele"
"net"
) )
type ChunkDivider struct { type ChunkDivider struct {
@ -167,7 +168,12 @@ func message2Chunks(message []byte, header *base.RtmpHeader, prevHeader *base.Rt
prevHeader = header prevHeader = header
} }
return out[:index] retVal := make([]byte, index)
copy(retVal, out[:index])
defer func() {
out = nil
}()
return retVal
} }
// copyBufferFromBuffers // copyBufferFromBuffers

Loading…
Cancel
Save