title: Error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
body: <p>I'm trying to run nextjs project in my localhost <code>http://localhost:3000</code>
  by doing <code>npm run dev</code> but it is giving me the error as</p>
  
  <pre><code>
  &lt;--- Last few GCs ---&gt;
  
  [7144:0000023E7D8307E0]   100544 ms: Mark-sweep 2017.9 (2023.0) -&gt; 2017.6 (2023.0) MB, 2836.9 / 0.1 ms  (average mu = 0.114, current mu = 0.006) allocation failure scavenge might not succeed
  [7144:0000023E7D8307E0]   103850 ms: Mark-sweep 2018.3 (2023.0) -&gt; 2018.0 (2023.2) MB, 3299.7 / 0.1 ms  (average mu = 0.058, current mu = 0.002) allocation failure scavenge might not succeed
  
  
  &lt;--- JS stacktrace ---&gt;
  
  ==== JS stack trace =========================================
  
      0: ExitFrame [pc: 00007FF6624B4DDD]
  Security context: 0x0240ef4c08d1 &lt;JSObject&gt;
      1: createElement(aka createElement) [000002B80EA54E01] [D:\Nitin\Practice UDEMY\SEO BLOG\frontend\node_modules\react\cjs\react.development.js:~727] [pc=00000262C81DBB66](this=0x03518e6804b1 &lt;undefined&gt;,0x03518e683eb9 &lt;String[#4]: meta&gt;,0x035350b9c5b9 &lt;Object map = 0000028E2A4AC9E9&gt;,0x03518e6804b1 &lt;undefined&gt;)
      2: arguments adaptor frame: 2-&gt;3
      3:...
  
  FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
  
  Writing Node.js report to file: report.20200507.191248.7144.0.001.json
  Node.js report completed
   1: 00007FF6618B363F napi_wrap+128063
   2: 00007FF661852836 public: bool __cdecl v8::base::CPU::has_sse(void)const __ptr64+35142
   3: 00007FF6618534F6 public: bool __cdecl v8::base::CPU::has_sse(void)const __ptr64+38406
   4: 00007FF662069F4E private: void __cdecl v8::Isolate::ReportExternalAllocationLimitReached(void) __ptr64+94
   5: 00007FF662052021 public: class v8::SharedArrayBuffer::Contents __cdecl v8::SharedArrayBuffer::Externalize(void) __ptr64+833
   6: 00007FF661F1E57C public: static void __cdecl v8::internal::Heap::EphemeronKeyWriteBarrierFromCode(unsigned __int64,unsigned __int64,class v8::internal::Isolate * __ptr64)+1436
   7: 00007FF661F297D0 public: void __cdecl v8::internal::Heap::ProtectUnprotectedMemoryChunks(void) __ptr64+1312
   8: 00007FF661F262F4 public: static bool __cdecl v8::internal::Heap::PageFlagsAreConsistent(class v8::internal::HeapObject)+3204
   9: 00007FF661F1BB13 public: bool __cdecl v8::internal::Heap::CollectGarbage(enum v8::internal::AllocationSpace,enum v8::internal::GarbageCollectionReason,enum v8::GCCallbackFlags) __ptr64+1283
  10: 00007FF661F1A184 public: void __cdecl v8::internal::Heap::AddRetainedMap(class v8::internal::Handle&lt;class v8::internal::Map&gt;) __ptr64+2452
  11: 00007FF661F3B36D public: class v8::internal::Handle&lt;class v8::internal::HeapObject&gt; __cdecl v8::internal::Factory::NewFillerObject(int,bool,enum v8::internal::AllocationType,enum v8::internal::AllocationOrigin) __ptr64+61
  12: 00007FF661CA0C51 public: class v8::internal::interpreter::JumpTableTargetOffsets::iterator &amp; __ptr64 __cdecl v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=(class v8::internal::interpreter::JumpTableTargetOffsets::iterator &amp;&amp; __ptr64) __ptr64+1665
  13: 00007FF6624B4DDD public: virtual bool __cdecl v8::internal::SetupIsolateDelegate::SetupHeap(class v8::internal::Heap 
  * __ptr64) __ptr64+546637
  14: 00000262C81DBB66
  npm ERR! code ELIFECYCLE
  npm ERR! errno 134
  npm ERR! frontend@1.0.0 dev: `next`
  npm ERR! Exit status 134
  npm ERR!
  npm ERR! Failed at the frontend@1.0.0 dev script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     C:\Users\Ganesh\AppData\Roaming\npm-cache\_logs\2020-05-07T13_43_08_709Z-debug.log
  </code></pre>
  
  <p>This is the debug log i found out </p>
  
  <pre><code>1 verbose cli [
  1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
  1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
  1 verbose cli   'run',
  1 verbose cli   'dev'
  1 verbose cli ]
  2 info using npm@6.13.4
  3 info using node@v12.16.1
  4 verbose run-script [ 'predev', 'dev', 'postdev' ]
  5 info lifecycle frontend@1.0.0~predev: frontend@1.0.0
  6 info lifecycle frontend@1.0.0~dev: frontend@1.0.0
  7 verbose lifecycle frontend@1.0.0~dev: unsafe-perm in lifecycle true
  8 verbose lifecycle frontend@1.0.0~dev: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Nitin\Practice UDEMY\SEO BLOG\frontend\node_modules\.bin;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\PostgreSQL\12\bin;C:\Program Files\Java\jdk-13\bin;C:\Users\Ganesh\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Ganesh\AppData\Roaming\npm;C:\Program Files\MongoDB\Server\4.2\bin;
  9 verbose lifecycle frontend@1.0.0~dev: CWD: D:\Nitin\Practice UDEMY\SEO BLOG\frontend
  10 silly lifecycle frontend@1.0.0~dev: Args: [ '/d /s /c', 'next' ]
  11 silly lifecycle frontend@1.0.0~dev: Returned: code: 134  signal: null
  12 info lifecycle frontend@1.0.0~dev: Failed to exec dev script
  13 verbose stack Error: frontend@1.0.0 dev: `next`
  13 verbose stack Exit status 134
  13 verbose stack     at EventEmitter.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
  13 verbose stack     at EventEmitter.emit (events.js:311:20)
  13 verbose stack     at ChildProcess.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
  13 verbose stack     at ChildProcess.emit (events.js:311:20)
  13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
  13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
  14 verbose pkgid frontend@1.0.0
  15 verbose cwd D:\Nitin\Practice UDEMY\SEO BLOG\frontend
  16 verbose Windows_NT 10.0.18362
  17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
  18 verbose node v12.16.1
  19 verbose npm  v6.13.4
  20 error code ELIFECYCLE
  21 error errno 134
  22 error frontend@1.0.0 dev: `next`
  22 error Exit status 134
  23 error Failed at the frontend@1.0.0 dev script.
  23 error This is probably not a problem with npm. There is likely additional logging output above.
  24 verbose exit [ 134, true ]
  </code></pre>
  
  <p>I also tried to solve the issue as suggested here 
  <a href="https://stackoverflow.com/questions/55613789/how-to-fix-fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-fa">How to fix “FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory” error
  </a> but it didn't work for me</p>
  
  <p>This is my package.json </p>
  
  <pre><code>{
    "name": "frontend",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
      "dev": "next",
      "build": "next build --max_old_space_size=4096",
      "start": "next start --max_old_space_size=4096"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
      "@zeit/next-css": "^1.0.1",
      "isomorphic-fetch": "^2.2.1",
      "js-cookie": "^2.2.1",
      "moment": "^2.24.0",
      "next": "^9.3.5",
      "nprogress": "^0.2.0",
      "react": "^16.13.1",
      "react-dom": "^16.13.1",
      "react-quill": "^1.3.5",
      "react-render-html": "^0.6.0",
      "reactstrap": "^8.4.1"
    }
  }
  
  </code></pre>