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 Apple Watch Series 11 42mm GPS is $100 Off
The Apple Watch Series 11 42mm GPS is $100 Off
1 Min Read
Apple Launching A New Education Hub In India Teaching Robotics and Swift Programming
Apple Launching A New Education Hub In India Teaching Robotics and Swift Programming
1 Min Read
Women’s and Men’s Golf Added to Apple Sports
Women’s and Men’s Golf Added to Apple Sports
1 Min Read
Apple Adding Civilization VII and Other Games To Apple Arcade
Apple Adding Civilization VII and Other Games To Apple Arcade
1 Min Read
AirPods 4 ANC Is $59 Off
AirPods 4 ANC Is $59 Off
1 Min Read
Apple Using 2NM Process For Their M6 and A20 Chip
Apple Using 2NM Process For Their M6 and A20 Chip
1 Min Read
iPhone 18 Models Will Not Have a Big Redesign
iPhone 18 Models Will Not Have a Big Redesign
1 Min Read
Launch of MacBook Pro M5 Pro and M5 Max Models is Approaching
Launch of MacBook Pro M5 Pro and M5 Max Models is Approaching
1 Min Read
Get the iPad Mini 7 256GB Wi-Fi at $99 Off
Get the iPad Mini 7 256GB Wi-Fi at $99 Off
1 Min Read
Mozilla Now Allows Turning AI Features Off
Mozilla Now Allows Turning AI Features Off
1 Min Read
Barcelona Passeig de Gràcia Apple Store Temporarily Closing
Barcelona Passeig de Gràcia Apple Store Temporarily Closing
1 Min Read
Apple’s Plans to Enter the Smart Glasses Market is Changing the Industry
Apple’s Plans to Enter the Smart Glasses Market is Changing the Industry
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?