We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What version of Go and system type/arch are you using?
Go
1.20 windows/intel x86 What version of GoFrame are you using?
GoFrame
v2.7.0
Can this bug be re-produced with the latest release? YES
What did you do?
func main() { glog.SetFlags(44)
ctx := context.Background() cache := gcache.New() for { key := guid.S() val := grand.B(10 * 1024 * 1024) err := cache.Set(ctx, key, val, 30*time.Minute) if err != nil { glog.Fatal(ctx, err) } _, err = cache.Remove(ctx, key) if err != nil { glog.Error(ctx, "delete failed", err) } time.Sleep(time.Millisecond * 10) }
}
What did you expect to see?
What did you see instead? 问题: 持续运行上述代码,内存会不断增加。
检查源码 发现当调用 func (c *AdapterMemory) Remove(ctx context.Context, keys ...interface{})接口时,会将过期时间设置为 gtime.TimestampMilli()-1000000,,并放入事件列表eventList中 在syncEventAndClearExpired 接口,只会对当前时间的前5秒的的数据进行清空 eks = []int64{ek - 1000, ek - 2000, ek - 3000, ek - 4000, ek - 5000}
因此,对于Remove掉的缓存,在expireSets里面会一直保留一份key值,导致内存会缓慢增加
The text was updated successfully, but these errors were encountered:
Showing top 10 nodes out of 11 flat flat% sum% cum cum% 1078.34kB 41.13% 41.13% 1078.34kB 41.13% github.com/gogf/gf/v2/os/gcache.(*adapterMemoryExpireTimes).Set 1027.94kB 39.21% 80.35% 1027.94kB 39.21% github.com/gogf/gf/v2/container/gset.(*Set).Add 515.19kB 19.65% 100% 515.19kB 19.65% unicode/utf16.Encode 0 0% 100% 515.19kB 19.65% fmt.Fprintln 0 0% 100% 515.19kB 19.65% fmt.Println (inline) 0 0% 100% 2621.47kB 100% github.com/gogf/gf/v2/os/gcache.(*AdapterMemory).syncEventAndClearExpired 0 0% 100% 2621.47kB 100% github.com/gogf/gf/v2/os/gtimer.(*Entry).Run.func1 0 0% 100% 515.19kB 19.65% internal/poll.(*FD).Write 0 0% 100% 515.19kB 19.65% internal/poll.(*FD).writeConsole 0 0% 100% 515.19kB 19.65% os.(*File).Write
Sorry, something went wrong.
Let me have a check.
Successfully merging a pull request may close this issue.
What version of
Go
and system type/arch are you using?1.20 windows/intel x86
What version of
GoFrame
are you using?v2.7.0
Can this bug be re-produced with the latest release?
YES
What did you do?
func main() {
glog.SetFlags(44)
}
What did you expect to see?
What did you see instead?
问题: 持续运行上述代码,内存会不断增加。
检查源码 发现当调用 func (c *AdapterMemory) Remove(ctx context.Context, keys ...interface{})接口时,会将过期时间设置为 gtime.TimestampMilli()-1000000,,并放入事件列表eventList中
在syncEventAndClearExpired 接口,只会对当前时间的前5秒的的数据进行清空
eks = []int64{ek - 1000, ek - 2000, ek - 3000, ek - 4000, ek - 5000}
因此,对于Remove掉的缓存,在expireSets里面会一直保留一份key值,导致内存会缓慢增加
The text was updated successfully, but these errors were encountered: