startMemoryTicker starts a ticker that periodically frees memory and optionally logs memory stats
(ctx context.Context)
| 280 | |
| 281 | // startMemoryTicker starts a ticker that periodically frees memory and optionally logs memory stats |
| 282 | func (i *Imgproxy) startMemoryTicker(ctx context.Context) { |
| 283 | ticker := time.NewTicker(i.config.Server.FreeMemoryInterval) |
| 284 | defer ticker.Stop() |
| 285 | |
| 286 | for { |
| 287 | select { |
| 288 | case <-ctx.Done(): |
| 289 | return |
| 290 | case <-ticker.C: |
| 291 | memory.Free() |
| 292 | |
| 293 | if i.config.Server.LogMemStats { |
| 294 | memory.LogStats() |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
no test coverage detected