Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: fix memory leak in chunk allocator #40989

Merged
merged 4 commits into from
Feb 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion util/chunk/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ func (a *allocator) Reset() {

//column objects and put them to the column allocator for reuse.
for id, pool := range a.columnAlloc.pool {
for _, col := range pool.allocColumns {
for i, col := range pool.allocColumns {
if (len(pool.freeColumns) < a.columnAlloc.freeColumnsPerType) && checkColumnType(id, col) {
col.reset()
pool.freeColumns = append(pool.freeColumns, col)
}
pool.allocColumns[i] = nil
}
pool.allocColumns = pool.allocColumns[:0]
}
Expand Down Expand Up @@ -196,6 +197,7 @@ func (cList *columnList) pop() *Column {
return nil
}
col := cList.freeColumns[len(cList.freeColumns)-1]
cList.freeColumns[len(cList.freeColumns)-1] = nil
cList.freeColumns = cList.freeColumns[:len(cList.freeColumns)-1]
return col
}
Expand Down