memory leak
yangbo-qc opened this issue · 1 comments
yangbo-qc commented
I wrote a test case and found that the memory has been rising, can you help me to see if it is a problem with my use or a memory leak, thank you.
But when I increase the number of tasks to 10000 level, this phenomenon will not appear.
system: MacOS 12.5 (m1)
go: 1.16
cron: github.com/robfig/cron/v3 v3.0.1
code:
func TestCron(t *testing.T) {
c := cron.New(cron.WithSeconds())
c.Schedule(cron.Every(time.Second), cron.FuncJob(func() {}))
c.Start()
go func() {
for {
var ms runtime.MemStats
runtime.ReadMemStats(&ms)
memory := int64(float64(ms.Alloc))
routines := runtime.NumGoroutine()
fmt.Printf(">> runtime: routines: %d, memory: %d\n", routines, memory)
time.Sleep(time.Second)
}
}()
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
<-sig
// Output:
// >> runtime: routines: 4, memory: 156304
// >> runtime: routines: 5, memory: 166616
// >> runtime: routines: 5, memory: 167528
// >> runtime: routines: 5, memory: 167968
// >> runtime: routines: 5, memory: 168808
// >> runtime: routines: 5, memory: 169632
// ...
}
yangbo-qc commented
When I delete the relevant cron code, there will still be this phenomenon, I understand that it may not be the problem of the library