Skip to content

os/gcache: memory leak #3817

@qinyuguang

Description

@qinyuguang

Go version

1.22

GoFrame version

2.7.4

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

package main

import (
	_ "net/http/pprof"

	"context"
	"log"
	"math"
	"net/http"
	"time"

	"github.com/gogf/gf/v2/os/gcache"
)

func main() {
	go func() {
		log.Println(http.ListenAndServe("localhost:18888", nil))
	}()

	ctx := context.Background()

	cacher := gcache.New(10000)

	for i := 0; i < math.MaxInt; i++ {
		_ = cacher.Set(ctx, i, i, 0)
		time.Sleep(time.Microsecond)
	}

	log.Println("done")
}

watch with monitor or use go pprof

What did you see happen?

memory leak

image image

What did you expect to see?

stable memory usage

Metadata

Metadata

Assignees

Labels

bugIt is confirmed a bug, but don't worry, we'll handle it.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions