func (b *Bucket) Take(n int64) int64 {
b.lock.Lock()
defer b.lock.Unlock()
if n > b.capacity {
n = b.capacity
}
if n > b.avail {
if n > b.fill() {
n = b.avail
}
}
b.avail -= n
return n
}
When the request volume is large and the user suddenly stops the request, it will cause a large number of locks, so that the goroutine does not release, and the memory is not released.