Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Free Up RAM Used by MongoDB on a VPS

MongoDB’s WiredTiger cache is only one part of its memory footprint. Measure resident memory, cache counters and cgroup limits before reducing the cache, then validate eviction, I/O, swap and latency—or resize the VPS when the workload cannot fit.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The safest way to free RAM is to measure what is actually consuming it, then reduce MongoDB’s WiredTiger cache only enough to leave room for the operating system and your other services. A VPS can show very little “free” memory even when MongoDB is behaving normally: WiredTiger keeps data in its own cache, while Linux uses otherwise available RAM for filesystem cache. If the process, workload and co-located services still exceed the VPS’s available memory after tuning, resize the VPS or move MongoDB to a separate machine.

Do not start by deleting Linux caches or killing mongod. Those actions can hide the symptom, increase disk I/O, or interrupt writes without reducing the workload that requires memory.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why MongoDB appears to use all the RAM

MongoDB’s WiredTiger storage engine and the Linux kernel use different memory pools. WiredTiger allocates an internal cache for frequently accessed database pages. Linux also fills unused RAM with filesystem cache for recently read data. Both pools can make a VPS look “full” in tools such as free or a hosting dashboard.

MongoDB’s current v7.0 mongod documentation describes the default WiredTiger cache as the larger of 50% of (RAM − 1 GB) or 0.256 GB. That figure is only the internal WiredTiger cache limit; it is not a cap on the complete mongod process and not a promise that half of the machine’s RAM will remain free.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

The process also needs memory for connections, query execution, indexes, aggregation stages, journaling and other overhead. The kernel, SSH, monitoring, web servers, application workers and any second database instance need their own headroom. Linux may then use much of the remainder as filesystem cache. MongoDB explicitly notes that it can use free memory through this filesystem cache in addition to the WiredTiger cache.

“Used” is not the same as memory pressure

Look at the available column from free -h, not just used. Filesystem cache is generally reclaimable when another process needs it. A host with a large cache and healthy available memory can be operating normally, while a host with modest “used” memory but almost no available memory and active swap may be under real pressure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Persistent swap activity, rapidly shrinking available memory, the kernel’s out-of-memory messages, rising disk latency and query timeouts are stronger signs of shortage than a large used-memory number by itself.

Measure before changing MongoDB

Take a baseline during representative workload. Record host memory, the resident size of mongod, WiredTiger cache usage, swap and disk activity. You need these values to choose a target and to tell whether a change helped.

Check host-level memory

free -h
swapon --show
top
ps -o pid,rss,vsz,cmd -C mongod

free -h reports total, used, free, shared, buffers/cache and available memory in human-readable units. Check whether swap is merely configured or is actively being used; a configured swap device is not proof that the system is paging. In top, sort by resident memory to identify other consumers. The ps command shows the resident set size (RSS) and virtual size for processes named mongod; RSS is the more useful first approximation of physical RAM occupied by the process.

Save the output with a timestamp, along with query latency and disk-I/O observations. A single quiet sample can understate the peak caused by reporting jobs, index builds or traffic bursts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect MongoDB’s resident memory and cache counters

Run serverStatus with an account that has permission to view server statistics:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
mongosh
use admin
db.serverStatus()

In the returned document, record these fields when present:

  • mem.resident: approximately the RAM used by the database process, reported in mebibytes (MiB).
  • wiredTiger.cache.maximum bytes configured: the configured WiredTiger cache ceiling in bytes.
  • wiredTiger.cache.bytes currently in the cache: current bytes held in that cache.
  • WiredTiger dirty-byte fields and eviction counters: indicators of pending writes and pressure to evict pages.

MongoDB warns that available statistics can vary by release, so check the field names returned by your installed version rather than assuming every counter exists. A cache that is near its maximum, high eviction activity and increasing disk reads after a change indicate that the cache may have been reduced too far for the workload.

Check cgroup or container limits

If MongoDB runs in Docker, LXC, Kubernetes or another cgroup, the process may see less memory than the VPS itself. From mongosh, inspect:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
db.hostInfo()

Compare hostInfo.system.memLimitMB with the VPS provider’s physical-RAM figure. MongoDB sizes its default cache against memory available to the process. Setting a cache based on the host’s RAM while the container has a smaller limit can leave no room for the process or its sidecars.

Understand what the cache setting does—and does not do

The WiredTiger setting controls one pool. In a YAML configuration it is commonly expressed as:

storage:
  wiredTiger:
    engineConfig:
      cacheSizeGB: 0.5

You can use cacheSizePct instead of cacheSizeGB, following the syntax documented for your installed MongoDB version. Neither option limits total mongod memory. Connections, operation working sets, index builds, internal structures, memory-mapped components where applicable, and the operating system remain outside that number.

MongoDB documents an effective lower bound beginning at 0.256 GB for configured cache values. Treat that as a documented minimum range, not as a recommendation for every deployment. A tiny cache can force frequent eviction and turn a memory problem into sustained disk I/O and higher latency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Calculate headroom instead of copying an example

First estimate the memory that must remain outside WiredTiger:

  • the measured resident footprint of mongod that is not explained by the cache;
  • the operating system and filesystem-cache needs;
  • your application, web server, workers, monitoring and SSH sessions;
  • any second mongod or other database;
  • a safety margin for traffic spikes, backups, index builds and maintenance.

Subtract those requirements from the memory limit visible to MongoDB. The remainder is the upper boundary for a trial cache value, and it should not be treated as a guaranteed free pool. Start with a modest reduction, observe the workload, and adjust only with evidence. The default assumes one mongod on a machine; multiple instances require their allocations to be planned together.

Reduce the WiredTiger cache safely

1. Confirm the active configuration

Find the configuration file used by the running service; on many Linux packages it is /etc/mongod.conf, but package and image layouts differ. Check the service definition or the process command line before editing. Make a dated backup of the file and note the current cache setting so rollback is immediate.

sudo cp /etc/mongod.conf /etc/mongod.conf.before-cache-change

Do not add a second conflicting storage.wiredTiger.engineConfig block. Edit the existing hierarchy and choose either cacheSizeGB or cacheSizePct, not both unless your version’s documentation explicitly permits that combination.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Choose a conservative trial value

Set a value that leaves room for the measured non-cache consumers. The following is only a syntax example; it is not a universal recommendation:

storage:
  wiredTiger:
    engineConfig:
      cacheSizeGB: 0.5

Do not blindly use 0.5 GB. On a larger VPS it may be unnecessarily restrictive; on a small container it may still be too large. Keep the value below the memory available to the container or cgroup, and account for the application and kernel before deciding.

3. Restart during a maintenance window

Changing the setting normally requires a mongod restart. Use the service manager appropriate to your installation, for example:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
sudo systemctl restart mongod
sudo systemctl status mongod --no-pager

Some container deployments restart through an orchestrator instead. Confirm that the service returns to a healthy state, accepts authenticated connections and has the expected replica-set or standalone role before sending production traffic to it. Keep the previous configuration available until validation is complete.

4. Verify after the restart

Repeat free -h, ps, db.serverStatus() and, where relevant, db.hostInfo(). Compare:

  • mem.resident and the RSS of mongod;
  • the configured and current WiredTiger cache bytes;
  • eviction work, dirty bytes and disk reads;
  • available memory, swap activity and application latency.

A lower resident footprint with acceptable latency is the intended result. If eviction counters climb sharply, dirty bytes remain high, disk I/O saturates or queries slow, restore the prior value and investigate workload or capacity rather than repeatedly shrinking the cache.

Free memory used by competing services

Cache tuning cannot solve a VPS where several services collectively need more RAM than the machine provides. Use top or your process supervisor to identify non-MongoDB consumers, then remove or reconfigure only those you understand.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Stop unused or duplicate workloads

  • Disable development servers, abandoned workers and scheduled build jobs that run on the database host.
  • Reduce application-worker concurrency if it creates more simultaneous in-memory requests than the VPS can handle.
  • Check for a second mongod, test database or backup process using the same machine.
  • Schedule index builds, exports and reports outside peak periods; these operations can require temporary working memory and generate additional I/O.

MongoDB’s default cache assumption is effectively one database process per machine. If multiple instances are intentional, assign each a smaller cache and reserve memory for their combined overhead instead of allowing independent defaults to compete.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Should you clear Linux filesystem caches?

Usually, no. Linux may reclaim filesystem cache automatically when applications need memory. Manually dropping caches can make a dashboard’s “used” number fall for a short time, but it does not lower the WiredTiger limit or reduce the amount of data your workload needs. The kernel and MongoDB will refill the cache, often causing extra disk reads in the meantime.

Cache dropping can be a controlled diagnostic when investigating whether filesystem cache is masking a measurement, but it is not a production remedy. If you perform such a test, record the before-and-after latency and I/O, and do not interpret the temporary reduction as capacity that has been permanently recovered.

Use swap as an emergency cushion, not a sizing strategy

A small, fast swap area can provide time for an occasional memory spike and reduce the chance of an immediate out-of-memory kill. It does not create RAM. Sustained MongoDB paging usually produces high latency and indicates that the workload, cache allocation or VPS size is unsuitable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After enabling or resizing swap, monitor swap-in and swap-out activity, query latency and disk utilization. If the system continuously pages, stop treating swap as a fix: reduce competing work, tune the cache based on measurements or move to a larger-RAM instance.

When a VPS resize is the correct fix

Choose a larger VPS or a separate database instance when the measured process, operating system, filesystem cache, application and safety margin still exceed available memory after reasonable cache tuning. MongoDB does not publish one universal RAM number because the correct size depends on dataset working set, connection count, indexes, query patterns, background jobs and co-located software.

A resize preserves more cache headroom and generally avoids the eviction and I/O penalty of an aggressively small cache. Before scheduling it, capture baseline values for resident memory, configured and current cache bytes, eviction activity, swap use, query latency and disk I/O. Repeat the same measurements afterward so the capacity decision is reviewable rather than based on a hosting-dashboard percentage.

Choose the remedy by trade-off

Remedy Immediate headroom Performance effect Persists after restart? Operational risk Cost
Reduce WiredTiger cache Usually frees part of the internal cache allocation More eviction and potentially more disk I/O Yes, if saved in configuration Requires restart and workload validation No infrastructure cost
Stop or reconfigure competing services Depends on the identified process Can affect the stopped workload; may improve database stability Only if service configuration is changed Risk of interrupting an undiscovered dependency No infrastructure cost
Drop filesystem caches Temporary and often reclaimed quickly Extra reads and possible latency spike No Diagnostic only; poor production remedy No infrastructure cost
Add swap Provides emergency virtual-memory cushion Paging can be dramatically slower than RAM Yes, when configured persistently Can conceal an undersized VPS Usually small storage cost
Resize VPS or separate MongoDB Adds durable physical-memory capacity Preserves cache and reduces eviction pressure Yes Migration, maintenance and configuration planning Higher recurring infrastructure cost

Troubleshooting common outcomes

The VPS still reports high memory after reducing the cache

Recheck mem.resident, RSS and wiredTiger.cache.bytes currently in the cache. The cache setting does not cap connections, indexes, operation memory or filesystem cache. Identify the largest remaining process with top and compare the cgroup limit if the database is containerized.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The cache setting appears to have no effect

Confirm that you edited the configuration actually used by the running process, that the YAML indentation is valid and that the service restarted successfully. Query serverStatus after restart to see the effective maximum configured bytes. In a container, a mounted configuration file or orchestration manifest may override the host file.

Queries became slower after the change

Check eviction counters, dirty bytes and disk I/O against your baseline. A smaller cache may be evicting hot pages too frequently. Restore the previous value or choose an intermediate value, then reduce other consumers or resize the VPS instead of continuing to shrink WiredTiger.

MongoDB was killed by the operating system

Inspect kernel and service logs for out-of-memory events, then compare the event time with free -h, swap and application-worker activity. A cache reduction can help only if it leaves enough room for process overhead and the workload. If the combined requirement still exceeds the limit, add RAM or move the database.

A container behaves differently from the VPS host

Use db.hostInfo() and read hostInfo.system.memLimitMB. Size the cache against that limit, not the host’s advertised RAM. Also account for memory reserved by sidecars, agents and the container runtime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operational checklist

  1. Record free -h, swap status, top or ps output, MongoDB serverStatus cache fields and application latency.
  2. Check db.hostInfo() when a cgroup or container may impose a lower limit.
  3. Estimate non-cache memory needs and leave explicit headroom for the kernel, filesystem cache, applications and maintenance.
  4. Back up the active configuration and make one conservative cache change.
  5. Restart through the correct service manager during a maintenance window.
  6. Repeat the measurements and watch eviction, dirty bytes, disk I/O, swap and latency under representative traffic.
  7. Roll back if performance degrades; remove competing consumers or resize the VPS if the workload still does not fit.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.