chen3feng / stl4go

Generic Container and Algorithm Library for Go
Apache License 2.0
313 stars 49 forks source link

Vector删除操作可能会内存泄露 #117

Closed goldpasser closed 1 year ago

goldpasser commented 1 year ago

https://github.com/golang/go/issues/54650 https://natan36.medium.com/gos-memory-leak-caused-by-slice-742d668bcfa6 如果Vector存放的是指针,删除有可能内存泄露。

chen3feng commented 1 year ago

是的

On Sun, Jun 25, 2023, 15:28 goldpasser @.***> wrote:

golang/go#54650 https://github.com/golang/go/issues/54650 https://natan36.medium.com/gos-memory-leak-caused-by-slice-742d668bcfa6 如果Vector存放的是指针,删除有可能内存泄露。

— Reply to this email directly, view it on GitHub https://github.com/chen3feng/stl4go/issues/117, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPH4SWZONR3JK3UIKTWBV3XM7SDTANCNFSM6AAAAAAZS7L4ZY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

chen3feng commented 1 year ago

有什么好的方案吗?

chen3feng commented 1 year ago

Pop和Remove确实会,我改为用零值填充

goldpasser commented 1 year ago

好像也只能这样了