Search code examples
ruby-on-railsreactjsantdwebpackerapache-mina

Antd design - Heap out of memory - webpacker


I am using rails gem mina for deploying my RubyonRails & React application into production

added antd npm package and deployed. so far no issue

when I try to import something from antd eg:

import { Icon, List } from 'antd'

Below issue is coming

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
        1: node::Abort() [/usr/bin/node]
        2: 0x8cd14c [/usr/bin/node]
        3: v8::Utils::ReportOOMFailure(char const*, bool) [/usr/bin/node]

Solution

  • Which version of node, webpack-dev-server are you running? Some older versions of webpack-dev-server had a memory leak

    You might want to specifically allow the V8 engine more RAM with something like this :

    node --max-old-space-size=4096 yourFile.js
    

    or in your package.json if you're using create-react-app :

    "start": "react-scripts --max_old_space_size=4096 start"
    

    (I put 4096 for 4GB of RAM but you can go higher if needed obviously).