hunterloftis / hunterloftis/pbr

Memory Leak - goroutine not cleaned up when stopping frame

Open
#44 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.2k
Forks
40
PR merge metrics
No merged PRs in 30d

Description

Hi, first of all - really cool project! Thank you so much for sharing!

I've been trying to make animations with this package for educational purposes and have had success so far. I came across a memory leak in the package, specifically cleaning up the process goroutine defined in render/frame.go. I have no idea what the best way to fix this.

It seems that we're stuck on reading from the channel in the for loop in the process function.
This causes all the linked data to stay in memory when rendering multiple frames in a sequence.

I was able to fix the leak by modifying the Stop method in frame.go to close the channel off. I can't close it off right away because there might still be tracers which send to the channel, so I put a timer in. I realize this is bad, but I haven't yet looked at a better way to handle this.

```golang
//render/frame.go
func (f *Frame) Stop() {
if f.active.Set(false) {
for _, w := range f.workers {
w.stop()
}

go func() {
time.Sleep(time.Second * 10)
close(f.in)
}()
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.