Skip to content

Commit

Permalink
delete queue elements before remove. allow gc to collect them for low…
Browse files Browse the repository at this point in the history
…er memory pressure
  • Loading branch information
fzwoch committed Sep 25, 2023
1 parent 60e0807 commit f4c0945
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ func filter_video(data C.uintptr_t, frame *C.struct_obs_source_frame) *C.struct_
for len(h.queue) > 0 && h.queue[0].DoneProcessing {
h.SenderSend(h.queue[0].Buffer)
h.pool.Put(h.queue[0].ImageBuffer)

h.queue[0] = nil
h.queue = h.queue[1:]
}
}(p)
Expand Down
2 changes: 2 additions & 0 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ func output_raw_video(data C.uintptr_t, frame *C.struct_video_data) {
for len(h.queue) > 0 && h.queue[0].DoneProcessing {
h.SenderSend(h.queue[0].Buffer)
h.pool.Put(h.queue[0].ImageBuffer)

h.queue[0] = nil
h.queue = h.queue[1:]
}
}(p)
Expand Down
1 change: 1 addition & 0 deletions source.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func (t *teleportSource) newPacket(p *Packet) {
}
}

t.queue[0] = nil
t.queue = t.queue[1:]
}
}(p)
Expand Down

0 comments on commit f4c0945

Please sign in to comment.