JavaScript Heap Out of Memory Error: Causes & How to Fix

Reason behind this error could be insufficient space allocated

by Srishti Sisodia
Srishti Sisodia
Srishti Sisodia
Srishti Sisodia is an electronics engineer and writer with a passion for technology. She has extensive experience exploring the latest technological advancements and sharing her insights through informative... read more
Reviewed by Alex Serban
Alex Serban
Alex Serban
Windows Server & Networking Expert
After moving away from the corporate work-style, Alex has found rewards in a lifestyle of constant analysis, team coordination and pestering his colleagues. Holding an MCSA Windows Server... read more
Affiliate Disclosure
  • The reason behind this could be invalid page table size, or issues with function call stack.
  • This guide will discuss troubleshooting steps to fix the error.
JavaScript Heap Out of Memory Error Causes & How to Fix
Easily get rid of Windows errors Fortect is a system repair tool that can scan your complete system for damaged or missing OS files and replace them with working versions from its repository automatically. Boost your PC performance in three easy steps:
  1. Download and Install Fortect on your PC.
  2. Launch the tool and Start scanning
  3. Right-click on Repair, and fix it within a few minutes
  • 0 readers have already downloaded Fortect so far this month

If you have encountered the JavaScript heap out-of-memory error, this guide can help! This often happens if the application runs out of memory. We will cover all the available fixes right after discussing the causes of the same. Let’s start! 

What causes the JavaScript heap out of memory error? 

There could be various reasons why the project crashed and presented you with this error; some of the common ones are mentioned here: 

  • Large objects present – If the code has a lot of large objects, then memory consumed by those objects collectively leads to an overload, hence the error.
  • Insufficient amount of memory allocated – If the default amount of memory allocated by Node.js is insufficient to complete a command, you might encounter this error.  
  • Memory leaks – As the app grows, it is important to delete some objects you don’t need; if not done, you might get this error. 
  • Large data structures – If you work with large data structures such as arrays or matrices, it can consume a lot of space, causing this error.
  • Infinite loops – Infinite loops use memory pretty fast, and it might cause this error.

What can I do to fix the JavaScript heap out of memory error? 

1. Use the Control Panel 

  1. Press Windows + E to open Windows Explorer.
  2. Go to This PC, right-click it, and select Properties.Properties javaScript Heap Out of Memory Error
  3. From the next page, select Advanced system settings.Advanced system settings javaScript Heap Out of Memory Error
  4. Switch to the Advanced tab, and click Environment VariablesEnvironment Variables
  5. Click New on either System variables (changes apply to the entire computer)  or User variables ( applies the changes to a user account).New
  6. On the next window, for the Variable name: enter Node_Options.
  7. Now for Variable value: –max-old-space-size=4096Click OK javaScript Heap Out of Memory Error
  8. Click OK. You can change 4096 to 8192 as well to allocate more space.
  9. On the Environment Variable window, click OK.
  10. Now click Apply and OK to save the changes. 

2. Use the PowerShell

  1. Press the Windows key, type PowerShell, and click Run as administrator. Powershell 2 javaScript Heap Out of Memory Error
  2. Copy and paste the following command and press Enter: env:NODE_OPTIONS="--max-old-space-size=4096"
  3. To temporarily solve the issue, you can type the following command and press Enter before opening the app: set NODE_OPTIONS=--max-old-space-size=4096

So, these are methods to fix the JavaScript heap out of memory error. To avoid this error in the future, it is advised to split your data into smaller chunks and delete the objects which are no longer needed. Try them and let us know what worked for you in the comments section below. 

Still experiencing issues?


If the above suggestions have not solved your problem, your computer may experience more severe Windows troubles. We suggest choosing an all-in-one solution like Fortect to fix problems efficiently. After installation, just click the View&Fix button and then press Start Repair.

This article covers:Topics: