0

I was trying to deply an ant design pro project on digital ocean droptlet using nginx . but it shows javascript heap out of memory since i am very new at deploying project on sever i have totally stuck here and unable to find any idea to solve this problem.

looking some expert solution

enter image description here

Tanjin Alam
  • 1,728
  • 13
  • 15
  • There isn't enough memory to build your project on the server. Increase memory on the VM or enable swap. – AKX Jun 08 '21 at 18:05
  • Swap will add virtual memory to your VM. It will be slow to build, but should work. See eg. https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04 – AKX Jun 08 '21 at 18:37

1 Answers1

1

There is two solution for this problem.

  1. increase server ram
  2. create dummy swap memeory
  3. This error occurs when the memory allocated for the executing application is less than the required memory. By default, the memory limit in Node.js is 512 MB.

first approach is totally server-administrator work second approach

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

Execute this 3 line code to create 1gb swap memory. which will work as your virutal ram.

third approach to increase this amount, you need to set the memory limit argument —-max-old-space-size. It will help avoid a memory limit issue. execute this line of code each time you before you build your project

This error occurs when the memory allocated for the executing application is less than the required memory. By default, the memory limit in Node.js is 512 MB. To increase this amount, you need to set the memory limit argument —-max-old-space-size. It will help avoid a memory limit issue.

node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb

more details for node-max-old-space

Tanjin Alam
  • 1,728
  • 13
  • 15