Details
-
Bug
-
Resolution: Fixed
-
Major
-
Morpheus, 7.6.2
-
Untriaged
-
0
-
Unknown
Description
The logic for pooling byte slices is based on capacity (and not the length) of the input slice -
func (p *DataPoolImpl) PutByteSlice(doneSlice []byte) { |
sliceCap := uint64(cap(doneSlice))
|
i := sort.Search(NumOfSizes, func(i int) bool { |
return sliceCap <= p.byteSlicePoolClasses[i] |
})
|
if i >= 0 && i < NumOfSizes { |
p.byteSlicePools[i].Put(doneSlice)
|
}
|
}
|
So when we get from the dataPool, we need to make sure that we expand the slice to sizeRequested (which otherwise will be limited by the length of the got slice from the pool which has a capacity of atleast the size that was requested, but the length can be way less than requested size) before using it further. In the current logic, we can therefore fall short with respect to the length of the slice in some cases later.