fix: memory leaks with BufferFactory being held

This commit is contained in:
David Zhao
2021-06-14 22:53:29 -07:00
parent 48a9971b3a
commit 2cecbad29d
4 changed files with 16 additions and 5 deletions
+8
View File
@@ -6,7 +6,9 @@ import (
"sync/atomic"
"time"
"github.com/go-logr/zapr"
"github.com/livekit/protocol/utils"
"github.com/pion/ion-sfu/pkg/buffer"
"google.golang.org/protobuf/proto"
"github.com/livekit/livekit-server/pkg/logger"
@@ -27,6 +29,7 @@ type Room struct {
// map of identity -> Participant
participants map[string]types.Participant
participantOpts map[string]*ParticipantOptions
bufferFactory *buffer.Factory
// time the first participant joined the room
joinedAt atomic.Value
@@ -57,6 +60,7 @@ func NewRoom(room *livekit.Room, config WebRTCConfig, iceServers []*livekit.ICES
statsReporter: NewRoomStatsReporter(room.Name),
participants: make(map[string]types.Participant),
participantOpts: make(map[string]*ParticipantOptions),
bufferFactory: buffer.NewBufferFactory(config.Receiver.packetBufferSize, zapr.NewLogger(logger.GetLogger())),
}
if r.Room.EmptyTimeout == 0 {
r.Room.EmptyTimeout = DefaultEmptyTimeout
@@ -110,6 +114,10 @@ func (r *Room) GetStatsReporter() *RoomStatsReporter {
return r.statsReporter
}
func (r *Room) GetBufferFactor() *buffer.Factory {
return r.bufferFactory
}
func (r *Room) FirstJoinedAt() int64 {
j := r.joinedAt.Load()
if t, ok := j.(int64); ok {