Skip to content

Commit

Permalink
util: fix memory leak in chunk allocator (pingcap#40989)
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 authored and ghazalfamilyusa committed Feb 6, 2023
1 parent 1de1a07 commit c7990f0
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit c7990f0

Please sign in to comment.