修复内存泄漏

This commit is contained in:
gospider
2024-04-23 15:45:56 +08:00
parent b575a86081
commit 61ad52835b
4 changed files with 11 additions and 68 deletions

View File

@@ -271,11 +271,7 @@ func (obj *Response) ReadBody() (err error) {
return errors.New("already read body")
}
obj.readBody = true
bBody := bufferPool.Get().(*bytes.Buffer)
defer func() {
bBody.Reset()
bufferPool.Put(bBody)
}()
bBody := bytes.NewBuffer(nil)
if obj.bar && obj.ContentLength() > 0 {
_, err = io.Copy(&barBody{
bar: bar.NewClient(obj.response.ContentLength),