iLoungeiLounge
  • News
    • Apple
      • AirPods Pro
      • AirPlay
      • Apps
        • Apple Music
      • iCloud
      • iTunes
      • HealthKit
      • HomeKit
      • HomePod
      • iOS 13
      • Apple Pay
      • Apple TV
      • Siri
    • Rumors
    • Humor
    • Technology
      • CES
    • Daily Deals
    • Articles
    • Web Stories
  • iPhone
    • iPhone Accessories
  • iPad
  • iPod
    • iPod Accessories
  • Apple Watch
    • Apple Watch Accessories
  • Mac
    • MacBook Air
    • MacBook Pro
  • Reviews
    • App Reviews
  • How-to
    • Ask iLounge
Font ResizerAa
iLoungeiLounge
Font ResizerAa
Search
  • News
    • Apple
    • Rumors
    • Humor
    • Technology
    • Daily Deals
    • Articles
    • Web Stories
  • iPhone
    • iPhone Accessories
  • iPad
  • iPod
    • iPod Accessories
  • Apple Watch
    • Apple Watch Accessories
  • Mac
    • MacBook Air
    • MacBook Pro
  • Reviews
    • App Reviews
  • How-to
    • Ask iLounge
Follow US

Articles

Articles

How To Fix The “JavaScript heap out of memory” Error

Last updated: Jul 11, 2022 6:37 am UTC
By Lucy Bennett
How To Fix The "JavaScript heap out of memory" Error

Those who write complicated Node.js applications can run into the “JavaScript heap out of memory” error quite often. It can also happen when you run a program downloaded from another project. Check this guide to understand this error and the solution for it.


How To Fix The “JavaScript heap out of memory” Error

How Node.js Manages Memory

Node.js sets some memory limits by default to prevent applications from using too much memory and bogging down the whole system. The actual limits depend on your system’s architecture and the version of Node.js.

How To Fix The "JavaScript heap out of memory" Error

4GB of heap memory is the limit of the latest 64-bit Node.js versions. It consists of two spaces: old and new space. The old space is where Node.js stores older objects. Its size is controlled by the –max-old-space-size flag.


When your application produces a lot of objects, they can fill up the old heap space quickly, and Node.js will crash with a “JavaScript heap out of memory” error message.

How To Fix The Problem

You can avoid the error by raising the memory limit set by Node.js with the –max-old-space-size flag. Its value (in MB) is the new memory limit.

node –max-old-space-size=8192 yourscript.js

This command allows Node.js to execute yourscript.js with up to 8GB (8192MB) memory allocated. If you want to set this flag permanently, add it as an environment variable in your system.


On Linux/macOS, run this command:

export NODE_OPTIONS=–max-old-space-size=8192

On Windows: go to the Control Panel and select System. In the Advanced System Settings ta, click Environment Variables and then select New.

Enter NODE_OPTIONS and –max-old-space-size=8192 in the Variable name and Variable value fields, respectively. Finally, click Enter.

Conclusion

The “JavaScript heap out of memory” error happens when a Node.js program consumes too much memory in the old heap space. Raise the limit with the –max-old-space-size flag, and you should avoid the issue. Visit ITtutoria to learn more about similar errors


Latest News
The AirPods Pro 3 is $20 Off
The AirPods Pro 3 is $20 Off
1 Min Read
Exynos 2600 Chip 2nm Process Revealed by Samsung
Exynos 2600 Chip 2nm Process Revealed by Samsung
1 Min Read
New Celebrity Ad Campaign Featuring Travis Scott Released by Beats
New Celebrity Ad Campaign Featuring Travis Scott Released by Beats
1 Min Read
Australia Getting Hypertension Notification Feature
Australia Getting Hypertension Notification Feature
1 Min Read
The 14-inch MacBook Pro with M5 Chip 16GB RAM/512GB is $250 Off
The 14-inch MacBook Pro with M5 Chip 16GB RAM/512GB is $250 Off
1 Min Read
Noise and Static on AirPods Pro 3 Still Unfixed
Noise and Static on AirPods Pro 3 Still Unfixed
1 Min Read
New iMac with 24-inch OLED Display May be Brighter With 600 Nits
New iMac with 24-inch OLED Display May be Brighter With 600 Nits
1 Min Read
The 15-inch M4 MacBook Air 256GB Is $250 Off
The 15-inch M4 MacBook Air 256GB Is $250 Off
1 Min Read
Internal Kernel Debug Kit from Apple Reveals Tests for a MacBook with A15 Chip
Internal Kernel Debug Kit from Apple Reveals Tests for a MacBook with A15 Chip
1 Min Read
Apple Currently In Talks With Suppliers for Chip Assembly & Packaging of iPhones in India
Apple Currently In Talks With Suppliers for Chip Assembly & Packaging of iPhones in India
1 Min Read
Apple Allows Easier Battery Replacement For M5 MacBook Pro with 14-inch Display
Apple Allows Easier Battery Replacement For M5 MacBook Pro with 14-inch Display
1 Min Read
The Apple Watch SE 3 44mm GPS is $50 Off
The Apple Watch SE 3 44mm GPS is $50 Off
1 Min Read

iLounge logo

iLounge is an independent resource for all things iPod, iPhone, iPad, and beyond. iPod, iPhone, iPad, iTunes, Apple TV, and the Apple logo are trademarks of Apple Inc.

This website is not affiliated with Apple Inc.
iLounge © 2001 - 2025. All Rights Reserved.
  • Contact Us
  • Submit News
  • About Us
  • Forums
  • Privacy Policy
  • Terms Of Use
Welcome Back!

Sign in to your account

Lost your password?