Why Metabase heap sizing decides whether your instance stays up
A self-hosted Metabase that crashes with a Java heap space error or slows to a crawl under load usually has a memory problem before it has a query problem. Metabase's backend is written in Clojure and Java and ships as a JAR, so it runs on the Java Virtual Machine, and the JVM heap is the first-line limit on how much work the instance can hold at once. When the heap fills, the JVM cannot allocate memory for the next request, and the process fails. Teams usually need this work after one of three triggers: an OutOfMemoryError in the logs, a steady rise in user counts or concurrent dashboard viewers, or queries that return large result sets that must be held in memory before they render.
The memory model is the same across editions. The open source edition and the paid Starter, Pro and Enterprise plans all run the same backend JAR on the same JVM, so the heap limits that cause a crash on a free install will also cause one on a paid install with the same load. Plan license and support decisions separately from capacity. Before you change anything, confirm which Metabase version you run, which Java runtime it uses, and what memory the host or container gives the process, because the heap must fit inside that allocation with room left for the operating system and other processes. Metabase's troubleshooting guide covers the Java heap space error and how to allocate more memory to the JVM, and it is the right first read.
Memory settings and when each fits
This table compares the four levers a self-hosted operator has when Metabase runs out of memory: the JVM heap, the host or container limit, concurrent work, and the application database. Read each row for when the lever fits and what it costs, and use the troubleshooting guide for the supported way to allocate memory to the JVM before changing anything.
| Lever | When it fits | Trade-off |
|---|---|---|
| Raise the JVM maximum heap | OutOfMemoryError with a Java heap space message while the host still has free RAM beyond the current heap | A larger heap leaves less memory for the operating system, the database and other processes on the same host, and long garbage collection pauses can grow with heap size |
| Raise the host or container memory limit | The JVM heap is already sized sensibly but the container or VM is killed or swaps under load | Needs more capacity on the host or a higher container limit, which adds infrastructure cost and must be kept above the heap plus non-heap JVM memory |
| Reduce concurrent work | Memory use spikes with many simultaneous queries, large result sets or many users viewing dashboards at once | Queries wait longer in queues, and lowering Jetty threads or query volume can slow dashboards for users during peak periods |
| Move the application database off embedded H2 | The instance runs on the embedded H2 file for anything beyond a demo, or the team needs a database that can be backed up and monitored separately | Requires a migration with the same Metabase version that last wrote the H2 file, plus a database to operate, back up and patch |
| Confirm the supported allocation method first | Before any change to heap or container settings, to check the documented way to pass memory options to the JVM for your install type | Changing memory flags in the wrong place can have no effect, so confirm the setting took effect after restart |
How to size and raise the heap safely
This sequence turns a suspected memory problem into a tested, documented heap setting, so the instance stays stable under representative load without guesswork.
Record current memory limits and Java version
The team lead or platform engineer who runs the Metabase JAR records the Java version in use, the current maximum heap set for the process (typically through the JAVA_OPTS or the container memory settings), the host or container memory limit, and any other services sharing that machine. Confirm the Java version against what the Metabase installation documentation supports for your release before changing anything. The step is done when these values sit in a change record that someone else can read and check.
Reproduce the failure in the logs
Whoever on the team owns Metabase operations collects the application logs around the failure and searches for the Java heap space OutOfMemoryError message, noting the timestamp, the action that triggered it (a large query export, a heavy dashboard or a sync), and how often it recurs. Compare the timing with host memory and garbage collection behavior if you collect those metrics. The step is done when you can name a specific trigger that reproduces the crash on demand, or when you have confirmed that the error is not present and the heap is not the cause.
Confirm the cause before raising the heap
The engineer reviews the troubleshooting guide's guidance on allocating more memory to the JVM and checks whether the trigger is a sizing problem or a query problem, such as a very large result set or an unbounded export. Raising the heap is only one option, and a heap that is too large can starve the operating system or other services on the same host. The step is done when the team agrees, in writing, that a larger maximum heap is the right fix for this trigger on this host.
Set a larger maximum heap in a copy first
The platform engineer sets a higher maximum heap in a non-production copy of the instance, using the same Metabase version, the same application database and a representative set of data sources, and leaves the initial heap setting unchanged unless the troubleshooting guide asks otherwise. Keep the host memory headroom for the operating system and other processes in view while setting the value. The step is done when the copy starts cleanly with the new setting and the process reports the expected maximum heap.
Restart and verify under representative load
The engineer restarts the non-production copy and replays the workload that caused the failure, including the largest dashboards, exports and scheduled syncs the team runs, along with concurrent users if you expect them. Watch the logs for the OutOfMemoryError message and check that the process stays within the host memory limit. The step is done when the replayed workload completes without the error and the memory footprint stays within the margin you set in step three.
Apply the change to production with a rollback plan
After the copy passes, the team applies the same heap setting to production during a planned restart window, records the previous value so it can be reverted, and confirms that the application database backup is current. The platform engineer restarts the production instance and checks startup logs for errors. The step is done when production runs with the new setting and the change record shows the before and after values.
Watch memory use over time
The operations owner monitors the process memory and garbage collection activity over several days of normal use, comparing peak usage with the configured maximum and watching for the OutOfMemoryError message in the logs. If the heap still fills or errors recur, capture a heap dump or thread dump as described in the profiling guide, then analyze it before changing the setting again. The step is done when the team has a documented baseline for normal peak memory and a recorded decision on whether the setting holds.
Diagnosing Java heap space OutOfMemoryError
This pattern appears when one request loads more rows into memory than the heap can hold. Metabase processes results in the JVM, so a wide question with no row limit, a large CSV or XLSX export, or a pivot over a big result set can exhaust the heap in a short window. The crash usually happens close to the user action that triggered it, and the stack trace often points to result processing or serialization rather than to the scheduler.
- Log line: Look for
java.lang.OutOfMemoryError: Java heap spacein the Metabase application log, with the timestamp of the user request that was running at that moment. - Request context: Note the question or dashboard card, the export format and the user. Repeat the same action in a test environment to confirm it reproduces.
- Result size: Compare the number of rows and columns returned by the query against what the user expected. Wide text or JSON columns inflate memory use quickly.
- Concurrency: Check whether several users ran heavy exports at the same time, since each request holds its own result in memory.
- Likely cause: The workload exceeds the memory available per request, so the first fixes are row limits, narrower questions and scheduled exports instead of raw heap increases.
Confirm the exact trigger before changing any memory setting, because a heap increase only moves the threshold for this pattern.
This pattern looks different. Memory use climbs steadily between restarts, garbage collection recovers less each cycle, and the error appears only after a long uptime. The cause is usually something that retains objects over time, such as accumulated caches, long-lived sessions, or many concurrent background tasks that never fully release their memory. Heap growth that tracks user activity over several days deserves a profile rather than a guess.
- Trend data: Record heap usage at regular intervals through your monitoring stack so you can see whether the floor rises after each collection.
- Log pattern: Look for repeated slow garbage collection messages or long pauses before the first OutOfMemoryError appears.
- Timing: Compare the failure time with scheduled work such as sync, cache refresh and emailed subscriptions.
- Version: Note the Metabase version and whether it changed recently, since the release notes and the Metabase version support page show which versions still receive fixes.
- Likely cause: Retained objects or a leak in a long-running process, which calls for a heap dump and a profiling session rather than only a larger heap.
Confirm that the growth pattern repeats across restarts before opening a profiling task.
In containers, the process may be terminated by the container runtime or the orchestrator before the JVM reports an OutOfMemoryError at all. The JVM sizes its heap relative to the memory it can see, and the total process footprint includes more than the heap, such as thread stacks, metaspace and native memory. When the container limit is lower than the total footprint, the host kills the process and the logs stop abruptly with no Java exception.
- Exit status: Check the container or pod status for an out-of-memory termination reason, which the runtime records separately from the application log.
- Limit versus heap: Compare the container memory limit with the configured maximum heap and the other memory the JVM uses.
- Log gap: A sudden stop without a stack trace points to a host kill, while a Java heap error points to heap exhaustion inside the JVM.
- Node pressure: Look at whether other workloads on the same node were also evicted during the same window.
- Likely cause: The container budget is too small for the JVM footprint, so the fix is to raise the limit or reduce heap settings so the total fits.
Confirm the runtime's termination reason with your platform team before concluding that the heap itself is the problem.
Some crashes line up with scheduled jobs rather than with user activity. Metadata sync, field value scans and cache refresh jobs read from databases and hold results while they work. When several of these jobs overlap with a large database or with user queries, their combined memory demand can exceed the heap. The stack trace often names the scheduled task or the caching component, which is the most useful clue in this group.
- Schedule overlap: List the sync, scan and cache refresh times from the admin settings and find any that run at the same time as the failure.
- Stack trace owner: Identify whether the trace references sync, scan, caching or subscription code, which narrows the cause quickly.
- Database size: Note the size of the databases being synced, especially schemas with many tables or wide tables.
- Cache settings: Check whether caching is enabled for large questions, since cached results are stored and read back through memory.
- Likely cause: Overlapping background work on large sources, which calls for staggered schedules, narrower sync scope and a check of cache policies.
Confirm the schedule times and the trace owner, then test any change in a copy of the environment before applying it to production.
How the diagnosis path moves from symptom to dump
The path starts with a symptom such as a crash, a slow instance or a restart, then moves to the Metabase logs to look for a Java heap space OutOfMemoryError. The key decision is whether the cause is configuration, meaning the JVM was given too little memory for the deployment, or workload, meaning queries, caching or concurrent users are demanding more than the heap can hold. Raise the heap or reduce the load first. Only if the problem persists should you capture heap and thread dumps using the profiling guide, because those files are for analysis and contain sensitive data.
Decision path from a memory symptom to capturing dumps for analysis.
When heap and thread dumps are worth capturing
A heap dump is worth capturing when memory use keeps climbing or an OutOfMemoryError recurs and the cause is not obvious from the logs. It is a snapshot of every object the JVM holds at one moment, so it shows which classes occupy the most memory and what is keeping them alive. That answers questions a larger heap cannot: whether usage is a one-off spike from a very large query result, or whether something such as a cache, session store or connection-related object grows without limit. Capture one only when you have a specific question to answer, because the file is roughly the size of the memory it captures and takes time to write. Confirm the capture method, file location and any pause or memory cost with the profiling guide before you run it on a production node.
A thread dump answers a different question: what each thread is doing right now. It helps when Metabase is slow or appears hung, the heap is not growing, and requests pile up waiting on a lock, a pool or a remote database. Taking two or three dumps a few seconds apart shows whether threads are stuck in the same place, which is the signal that matters. Thread dumps are cheap to capture compared with heap dumps and usually come first in an investigation. Keep in mind that a thread dump can reveal query text, database host names and user identifiers, and a heap dump can contain the contents of query results, cached values, and connection details held in memory. Treat both files as sensitive: restrict who can read them, transfer them over encrypted channels, delete them once the investigation closes, and record who had access in your change or incident record.
Security and operational risks of memory dumps and restarts
Changing heap size and collecting dumps both touch production. The cards below cover the data exposure, user disruption, configuration drift and monitoring gaps that come with memory work on a self-hosted Metabase, and the controls to put in place before the work starts.
Heap dumps contain sensitive data
A heap dump is a snapshot of everything in JVM memory at one moment. For Metabase that can include query results, session data, connection details and possibly credentials in memory. Treat each dump as a copy of production data: store it only on restricted hosts, limit who can read it, and record who requested it and why. Confirm with your security team whether dumps fall under your data retention and classification rules before you collect one.
Profiling guideDelete dumps on a schedule
Dumps are large and easy to forget. Set a deletion step in the same runbook that collects them, and confirm that deletion covers backups, copies sent to a vendor or support channel, and any shared storage. Ask your storage team whether the deleted files are overwritten or whether they remain recoverable from snapshots, since that determines whether deletion meets your policy.
Restarts interrupt users and jobs
Changing -Xmx or other JVM flags means restarting the Metabase process. Active dashboard loads, question runs, embedded sessions and scheduled subscriptions stop during the restart. Pick a window with low use, check the schedule of sync and caching jobs, and tell users in advance. In a cluster, roll nodes one at a time so the service stays available.
Record heap changes in configuration management
Heap settings often change under pressure and then drift from what is deployed. Store the JVM options in the same version-controlled configuration as the rest of the deployment, such as the container spec, systemd unit or environment file. Each change should have a reason, an owner, a date and a rollback value. Without this record, the next upgrade or host rebuild can silently remove the setting.
Alert before memory runs out
An OutOfMemoryError usually follows a long period of rising memory use, so an alert on the final failure is too late. Track heap use over time with your monitoring stack and set a threshold that leaves time to act, such as sustained high occupancy after garbage collection. Check whether your monitoring can read JVM metrics from the Metabase host, and confirm who receives the alert outside business hours.
Run profiling in a controlled environment
Profilers and thread dump tools attach to a live JVM, pause it, or add overhead while they run. Run them on a staging copy with production-like data volumes where possible, or on production only under a change ticket with a named operator and an observation window. Confirm that the profiling tool and its output are approved by your security team before it is installed on a server that holds production credentials.
Questions teams ask about Metabase memory before hiring help
How much does heap tuning cost in effort?
Effort depends mostly on how many Metabase instances you run, how much data and how many concurrent users they serve, and whether the problem can be fixed by changing a memory setting or needs a heap or thread dump analyzed. A single instance with a clear OutOfMemoryError in its logs and a known container limit is a small, bounded task. A cluster with intermittent crashes, several environments and unclear causes takes longer because each hypothesis needs a test under load. Ask any partner for a fixed-scope quote that lists the instances, environments, logs and dumps in scope, and the retest criteria. Costs recur only if you buy ongoing support or retainers for later tuning, upgrades or monitoring.
How long does it take to size Metabase memory properly?
The duration is set by the diagnosis rather than the setting change itself. Raising the heap through the documented JVM options is quick once the cause is known, but confirming that memory was the actual bottleneck, and that the fix holds under realistic dashboard and query load, takes longer. Expect time for collecting logs and container metrics, reproducing the workload, reviewing any dumps, and rerunning the same tests after the change. Confirm the schedule with your partner or internal team against your own environment, since no fixed duration applies to every deployment.
What does the internal team need to provide for this work?
The team needs access to the host or container running Metabase, its JVM options, the application logs covering the crash window, and the memory limits set by the orchestrator or systemd unit. Someone must also know the typical load, including dashboard count, concurrent viewers and the largest warehouse queries, because heap needs follow the work. For dump analysis, you need permission to capture dumps from production or a production-like copy, plus a secure place to store them, since dumps can contain query results and credentials held in memory.
Can our team size Metabase memory alone using the documentation?
Often yes, for a single instance with a clear error and a stable workload. Metabase's troubleshooting guide covers Java heap space OutOfMemoryError crashes and how to allocate more memory to the JVM, and its profiling guide explains heap and thread dumps. Teams with a Java operations background usually manage the setting change and log review in-house. Outside help becomes more useful when crashes recur across several instances, when dumps need analysis, or when no one owns the container limits and the database connection settings that interact with memory.
Does the open source edition handle memory differently from paid plans?
No. Memory sizing and JVM behavior depend on the runtime model, which is the same backend JAR across editions. Metabase's repository ships the open source edition under the AGPL and its commercial editions under the Metabase Commercial Software License, but the licensing difference does not change how the JVM allocates RAM or how heap and thread dumps are taken. Paid plans add features such as SSO and usage analytics, which affect load patterns indirectly, not the memory model itself. Confirm any edition-specific behavior with Metabase before relying on it.
What should we ask a partner to confirm before hiring help?
Ask for a written scope that names the instances, environments and symptoms to investigate, the evidence you will receive, such as tuned JVM settings, a before and after load result and a written explanation of the cause, and the retest step. Ask how they handle heap and thread dumps, where those files are stored and who deletes them. Confirm whether the work includes container limit changes, changes to connection pools or sync schedules, and what happens if the first fix does not hold. DeployOpen plans and delivers fixed-scope engagements against a written scope, and the quote follows from that scope.
What risks come with changing Metabase memory settings?
Raising the heap without understanding the cause can hide a problem such as a runaway query or a connection leak, and a larger heap can cause longer garbage collection pauses or push the host into swapping if the container or machine has no spare RAM. Setting the heap higher than the container limit can cause the process to be killed rather than fail with a clear error. Test changes in a non-production copy first, record the before and after behavior, and keep the previous settings available for rollback.
How upgrades and the application database affect memory planning
Plan memory around upgrades, not only around steady-state load. Metabase runs application database migrations automatically when a new JAR starts, so the first boot after an upgrade does more work than a normal restart, and the schema changes it makes can shift how the instance behaves under load. Before any upgrade, take a backup of the application database, following the procedure in Upgrading Metabase. For major upgrades, the docs recommend reducing a cluster to a single node first because of a migration lock, which means your planned rolling restart will not apply to that step.
After the upgrade, recheck your heap settings rather than assuming the old values still fit. Confirm the new JAR starts with the same -Xmx value and container limit you tested, then watch heap use and GC activity through the first full working day, including scheduled syncs and dashboard refreshes. Confirm with your Metabase version's release notes whether the new release changes its memory footprint, since the docs do not give a general figure you can plan against. If the old settings no longer hold, you have time to adjust before users notice.
Rollback is the step most teams underplan. The recommended path is restoring the pre-upgrade application database backup, paired with the previous JAR. Running the migrate down command with the newer JAR is the documented alternative, but it depends on the migration history being reversible for your release. Rehearse the restore on a copy of the database before a production upgrade, and record the heap and thread settings that worked on the old version so you can return to them exactly.
How DeployOpen scopes and supports Metabase memory work
DeployOpen approaches Metabase JVM memory and heap sizing as a scoped piece of work inside your own infrastructure, starting from how your instance is hosted and how it behaves under real use. We plan the heap change, test it against your workload, and document the result so your own team can run it. Engagements are fixed-scope, with the terms agreed in writing before work starts.
How we scope
- Review the hosting model, JAR launch settings and current memory limits on your Metabase nodes
- Collect the OutOfMemoryError evidence, logs and symptoms that define the problem before any change
- Agree in writing which nodes, environments and heap changes are covered and what is excluded
How we build
- Set the heap and related JVM options in your deployment, one change at a time, with a recorded baseline
- Test the new settings against representative dashboard and query load in a non-production environment first
- Prepare heap and thread dump procedures so deeper profiling can run safely when symptoms return
How we hand over
- Document the final JVM settings, the reasoning behind them and the rollback steps for each change
- Walk your platform and operations engineers through reading memory signals, dumps and the profiling steps
- Deliver runbooks that state which limits to monitor and when to escalate a recurring memory fault
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer after handover
- Retainers can cover re-sizing after a Metabase upgrade or a change in user count or query volume
- Confirm with DeployOpen which support tier, response expectations and review cadence apply to your scope

