Memory
Leak Detection
Automatic detection and cleanup of memory leaks.
What is detected#
| Type | Auto Fix |
|---|---|
| Event listener accumulation | Warns |
| Cache overflow | Prunes |
| Timer accumulation | Warns |
| Global pollution | Warns |
| Unused module cache | Clears |
| High heap usage | Triggers GC |
Track resources#
typescript
import { trackTimer, trackCache } from '@AxilJS/memory'
const timer = trackTimer(setTimeout(work, 5000))
const cache = trackCache('sessions', new Map(), 10000)Per-request#
typescript
import { memoryMiddleware } from '@AxilJS/memory'
app.use(memoryMiddleware({ leakThresholdMb: 50, exposeHeader: true }))