(ctx context.Context, wg *sync.WaitGroup)
| 37 | } |
| 38 | |
| 39 | func (mm *MemoryMonitor) Run(ctx context.Context, wg *sync.WaitGroup) { |
| 40 | ticker := time.NewTicker(monitorInterval) |
| 41 | defer ticker.Stop() |
| 42 | defer wg.Done() |
| 43 | slog.Debug(fmt.Sprintf("memory monitor: started and will run every %v", monitorInterval)) |
| 44 | for { |
| 45 | select { |
| 46 | case <-ctx.Done(): |
| 47 | return |
| 48 | case <-ticker.C: |
| 49 | threshold := mm.profile.RuntimeMemoryProfileThreshold.Load() |
| 50 | mm.checkMemory(threshold) |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func (mm *MemoryMonitor) checkMemory(memoryThreshold uint64) { |
| 56 | // memoryThreshold == 0 means no need to monitor |
no test coverage detected