How Memory Grows When You Keep an AI Agent Running
The typical causes of memory use creeping up in an always-on AI agent, how to notice it, and how effective the simple safeguard of restarting is.

Ren

Procura
Typical causes of growth
- It keeps all the conversation history without any cutoff
- It piles up processed content in memory as logs without limit
- It moves on to the next job without properly cleaning up the space used in each one

Ren

Procura
The real fix and a stopgap
The right response is to find and fix the cause of the growth. But identifying the cause can take time. As a stopgap in the meantime, restarting the process on a schedule is simple but really does work in practice, because it resets everything that has piled up. Just don't forget that this is not a substitute for the real fix.
- Make memory usage viewable as a time series
- For conversation history, summarize the old parts or cut it off at a set amount
- As a stopgap, set up a restart at fixed intervals
- Don't paper over it with restarts; investigate the cause at the same time
Keep the monitoring light
It defeats the purpose if the mechanism that watches memory usage becomes heavy itself. If you keep recording the state at very short intervals, the records themselves start to strain memory and disk. Even recording once every few minutes is enough to catch an upward trend. Aim for monitoring that is light but continuous.
- Recording intervals of a few minutes are often enough
- Have old records deleted automatically so they don't pile up forever
- Set it up so you're notified only when growth is abnormal
Procura

Ren

Procura
Don't rely too much on swap
When memory runs short, having swap space makes it look as if things are still running. But swap is a substitute that uses the disk, so the more you lean on it, the more noticeably processing slows down. Don't settle for 'it hasn't crashed, so it's fine'; check swap usage together with memory, and if it's in constant use, treat it as a sign to add memory or investigate the cause.
- Check swap usage together with the memory trend
- Don't assume that a state where swap is always in use is normal
- Keep a stopgap swap setting separate from fixing the underlying memory shortage

Ren
This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.