Skip to content

Possible memory leak caused by slice #4137

@wk989898

Description

@wk989898

Memory leaks caused by slices in Go occur when a small, derived slice (or substring) holds a reference to a large underlying array, preventing the garbage collector from freeing the unused, large memory block. The entire original array remains in memory as long as a single sub-slice points to it.

Starting with 1.22, the new slices package and its Delete function uses clear to allow GC to free data even if it's represented by pointers.

Sub-issues

Metadata

Metadata

Assignees

Labels

type/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions