Ionic : can not build an ios app - FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

till date build command is working fine with

ionic cordova build ios -l -- --buildFlag="-UseModernBuildSystem=0"

but now its throwing error of CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I found command to resolve this issue but its still not working

ionic cordova build ios -l -- --buildFlag="-UseModernBuildSystem=0" --max_old_space_size=4096

I got these error in both command


<--- Last few GCs --->

[18798:0x10264e000]    15650 ms: Mark-sweep 988.6 (999.0) -> 988.5 (999.0) MB, 191.4 / 0.0 ms  (average mu = 0.677, current mu = 0.000) last resort GC in old space requested
[18798:0x10264e000]    15844 ms: Mark-sweep 988.5 (999.0) -> 988.5 (999.0) MB, 194.7 / 0.0 ms  (average mu = 0.480, current mu = 0.000) last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x3cdf8055be3d]
Security context: 0x31009211e6e9 <JSObject>
    1: exec [0x310092109239](this=0x3100ccfe71f9 <JSRegExp <String[96]: Component\s*?\(\s*?(\{([\s\S]*?)(\s*templateUrl\s*:\s*(['"`])(.*?)(['"`])\s*?)([\s\S]*?)}\s*?)\)>>,0x310067cc53d9 <Very long string[414409193]>)
    2: getTemplateMatch(aka getTemplateMatch) [0x3100ccfe5371] [/Users/user151571/ionic_project/ionic_project/node_modules/@ionic/ap...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x10003c597 node::Abort() [/usr/local/bin/node]
 2: 0x10003c7a1 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x1001ad575 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0x100579242 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 5: 0x100582744 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 6: 0x100554534 v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
 7: 0x100686109 v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/usr/local/bin/node]
 8: 0x10076bea8 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [/usr/local/bin/node]
 9: 0x10080e8b0 v8::internal::Runtime_RegExpExec(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
10: 0x3cdf8055be3d 
Error

    at new SubprocessError (/usr/local/lib/node_modules/ionic/node_modules/@ionic/utils-subprocess/dist/index.js:40:23)
    at ChildProcess.p.on (/usr/local/lib/node_modules/ionic/node_modules/@ionic/utils-subprocess/dist/index.js:128:27)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
  ionic Error
  ionic     at new SubprocessError (/usr/local/lib/node_modules/ionic/node_modules/@ionic/utils-subprocess/dist/index.js:40:23)
  ionic     at ChildProcess.p.on (/usr/local/lib/node_modules/ionic/node_modules/@ionic/utils-subprocess/dist/index.js:128:27)
  ionic     at ChildProcess.emit (events.js:189:13)
  ionic     at maybeClose (internal/child_process.js:970:16)
  ionic     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) +16s

Can any one have solution?