Out of Memory
Your bot uses more RAM than your plan allows, so the system stops it. On the Free plan the limit is 308 MB, which is plenty for most bots — as long as memory is kept under control.
What You See
- The server stops suddenly, with no error from your code (the process was killed — sometimes shown as exit code 137)
- The server restarts in a loop after running for a while
- The memory usage shown in your panel keeps climbing until the limit
- Or one of these messages:
console
# Node.js
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
# Python
MemoryError
Restart Loop With an Error?
If the console shows an error from your code before each restart, it's a crash, not a memory problem. Start with Identify Errors.
Common Causes
| Cause | Typical example |
|---|---|
| Library caches | discord.js / discord.py keep messages, members and presences in memory — it grows with the number of servers |
| Memory leaks | Event listeners or setInterval added inside a command, arrays/dicts that grow forever |
| Large files loaded at once | Reading a big JSON file or a whole image/video into memory |
| Heavy tools | Headless browsers (Puppeteer, Playwright), audio processing, machine learning models |
Measure Memory Usage
Log your bot's memory regularly to see whether it grows over time (leak) or is simply too high from the start:
Node.js
setInterval(() => {
const mb = Math.round(process.memoryUsage().rss / 1024 / 1024);
console.log(`[memory] ${mb} MB`);
}, 60_000);
Python
import resource
from discord.ext import tasks
@tasks.loop(minutes=1)
async def log_memory():
peak_mb = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss // 1024
print(f"[memory] peak {peak_mb} MB")
# Start it in on_ready: log_memory.start()
Reduce Memory Usage
Limit the Cache (discord.js)
index.js
const { Client, GatewayIntentBits, Options } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
makeCache: Options.cacheWithLimits({
...Options.DefaultMakeCacheSettings,
MessageManager: 50, // keep at most 50 messages per channel
PresenceManager: 0, // don't cache presences
}),
sweepers: {
...Options.DefaultSweeperSettings,
messages: { interval: 3600, lifetime: 1800 }, // drop messages older than 30 min
},
});
Limit the Cache (discord.py)
main.py
bot = commands.Bot(
command_prefix="!",
intents=intents,
max_messages=100, # default: 1000
member_cache_flags=discord.MemberCacheFlags.none(),
chunk_guilds_at_startup=False, # don't download every member list
)
Other Good Habits
- Only request the intents you need — fewer intents, fewer events and less cache (see Disallowed Intents)
- Register listeners once, at startup, never inside a command
- Use a database (SQLite, MariaDB) instead of keeping all your data in a big object in memory
- Stream large files instead of reading them entirely
- Avoid headless browsers on the Free plan — they need several hundred MB on their own
Need More RAM?
If your bot is optimized and still needs more memory, a paid plan gives you from 1512 MB (Starter) up to 8 GB (Expert). See Plans — and remember you can earn credits with the referral program.
Still Stuck?
Check the error index or open a ticket with your memory logs.