What drives memory use
- Runtime. Node.js and Python start small. The Java JVM reserves a heap up front, so JDA bots start bigger.
- Caches. Libraries cache guilds, channels, members and messages. More servers and members means more cache.
- Intents. The
GUILD_MEMBERSandGUILD_PRESENCESintents bring in a lot of data. Ask only for what you use. - Features. Audio and music, image generation and big in-memory lists all add up.
- Leaks. Arrays or maps that only ever grow will eventually reach any limit.
Rules of thumb by plan size
Scroll sideways
| RAM | 256 MB | 512 MB | 1 GB | 2 GB |
|---|---|---|---|---|
| Typically fits | Small Node or Python bot, few servers, light caching | Busier Node or Python bot; small JDA bot with a tuned heap | JDA bots, bots in many servers, a database on the side | Large or sharded bots, heavier processing |
| discordbothost plan | Free | Starter, $0.99/mo | Pro, $1.99/mo | Plus, $3.49/mo |
These are starting points, not guarantees. Watch your bot's graph.
How to measure
- Run the bot for a day under normal use.
- Watch peak memory, not the average. discordbothost shows live memory and CPU graphs on every plan.
- Pick a plan where the peak sits comfortably below the limit. When a container hits its limit, the process is killed, and that looks like the bot "randomly going offline".
Trimming memory
- discord.js: set
makeCachelimits (for example, cap the message cache) andsweepersto clear old entries. - discord.py: set
max_messages(orNone) on the client, and turn offmembersintents if you don't need them. - JDA: use
JDABuilder.createLight, turn off caches you don't use withdisableCache, and set-Xmx(or-XX:MaxRAMPercentage=75) so the heap stays below the container limit. - Store growing data in a database rather than in memory. discordbothost Pro includes 1 database, and Plus includes 2.
Where discordbothost fits
discordbothost plans grow in simple steps: 256 MB free, then 512 MB for $0.99, 1 GB for $1.99, and 2 GB for $3.49 a month. Each plan has a hard disk quota and its own container, so other customers' bots can't eat your memory. Swap is off, so the limit you see is the limit you get.
Questions
Is 256 MB of RAM enough for a Discord bot?
For a small discord.js or discord.py bot in a handful of servers, usually yes. Java (JDA) bots, music bots and bots that cache many members usually need 512 MB to 1 GB or more. Measure your bot's memory rather than guessing.
Why does my Java Discord bot use so much memory?
The JVM reserves heap up front and grows it until the maximum heap size. Set the maximum heap (-Xmx or -XX:MaxRAMPercentage) below your container's limit, leaving room for non-heap memory.
How do I reduce my bot's memory use?
Request only the gateway intents you need, limit library caches (members, messages), avoid storing large data in memory, and use a database for anything that grows.
Sources
Related
Why Does My Discord Bot Keep Going Offline?
7 common reasons a Discord bot goes offline (PC sleep, sleeping free hosts, crashes, memory, bad token, intents, rate limits) and how to fix each.
Updated · 4 min readRender Discord Bot Hosting: Free Limits and Setup
Can Render host a Discord bot? Choose a worker or HTTP service, understand free sleep limits, set build commands and move your bot safely.
Updated · 4 min readHow to Host a Discord Bot for Free (Step by Step)
Host a Discord bot 24/7 for free: create the bot, upload your discord.js, discord.py or JDA code to a free host, set the token, and keep it renewed.
Updated · 3 min read