internal/graphicscommand: Bug fix: memory leak at q.commands

Apparently, the part of a slice between len and cap-1 still holds
references. Release them explicitly.

Closes #1803
This commit is contained in:
Hajime Hoshi 2021-09-09 04:27:45 +09:00
parent 8f857daf3e
commit 5ac357959c

View File

@ -292,6 +292,13 @@ func (q *commandQueue) flush() error {
cs = cs[nc:] cs = cs[nc:]
} }
theGraphicsDriver.End() theGraphicsDriver.End()
// Release the commands explicitly (#1803).
// Apparently, the part of a slice between len and cap-1 still holds references.
// Then, resetting the length by [:0] doesn't release the references.
for i := range q.commands {
q.commands[i] = nil
}
q.commands = q.commands[:0] q.commands = q.commands[:0]
q.nvertices = 0 q.nvertices = 0
q.nindices = 0 q.nindices = 0