If the pool is a sync.Pool: Any item stored in the Pool may be removed automatically at any time without 18 // notification. If the Pool holds the only reference when this happens, the 19 // item might be deallocated. So placing an object in the pool does not guarantee it won’t be collected - causing a future allocation.
> On Mar 25, 2020, at 10:22 PM, steve tang <tsg...@gmail.com> wrote: > > chunkCrc32Hash := crc32.NewIEEE() > chunkBuf := bufferpool.GetInstance().Get() > //回收buffer > defer bufferpool.GetInstance().Put(chunkBuf) > writer := io.MultiWriter(chunkBuf, chunkCrc32Hash) > _, copyErr := io.Copy(writer, chunkResp.RawResponse.Body) > if copyErr != nil && copyErr != io.EOF { > logmgr.ErrorLogger(ctx, "fail to write chunk data to crc32 or buffer, req: > %s, err: %s", originReq.PrettyPrint(), copyErr) > return false, exception.OEFException(nil, http.StatusInternalServerError, > CopyChunkError, "internal server exception") > } > > In above codes, it writes chunk data to buffer pool, and the chunk data size > is 4MB. When I used golang tool pprof to export memory pprof, there about > 8MB space has been allocated. Could somebody help me why golang allocated > memory space increases? > > > <20200326-111844.png> > > > > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/6dbe93e6-9bb7-4112-87cb-085e68d9d393%40googlegroups.com > > <https://groups.google.com/d/msgid/golang-nuts/6dbe93e6-9bb7-4112-87cb-085e68d9d393%40googlegroups.com?utm_medium=email&utm_source=footer>. > <20200326-111844.png> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/D42FB691-68B9-4925-BF33-38CE78089673%40ix.netcom.com.