Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.
This repository was archived by the owner on May 1, 2020. It is now read-only.

Allocation failed - JavaScript heap out of memory #64

Closed

Description

@chack

Ionic Serve runs without problems, but Ionic run iOS gives me this:
I already updated to app-scripts 0.0.27 to get #44

[16:22:46] bundle prod started ...
<--- Last few GCs --->
167123 ms: Mark-sweep 1308.5 (1434.1) -> 1308.5 (1434.1) MB, 1012.0 / 0.0 ms [allocation failure] [GC in old space requested].
168098 ms: Mark-sweep 1308.5 (1434.1) -> 1308.5 (1434.1) MB, 975.3 / 0.0 ms [allocation failure] [GC in old space requested].
169101 ms: Mark-sweep 1308.5 (1434.1) -> 1318.0 (1418.1) MB, 1002.5 / 0.0 ms [last resort gc].
170079 ms: Mark-sweep 1318.0 (1418.1) -> 1327.5 (1418.1) MB, 977.2 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1de7fe7cfb51
1: decode(aka decode) [/Users/Jan/Documents/Wohntraum360/wohntraumapp_v2/wohntraumapp/node_modules/rollup/dist/rollup.js:~304] [pc=0x890dfd2cecf](this=0x1de7fe704381 ,mappings=0x2036de204201 <Very long string[11559331])
2: render [/Users/Jan/Documents/Wohntraum360/wohntraumapp_v2/wohntraumapp/node_modules/rollup/dist/rollup.js:8938] [pc=0x890e04420e6] (this=0x63e3a0f75d1 <a...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1:
node::Abort() [/usr/local/bin/node]
2:
node::FatalException(v8::Isolate*, v8::Localv8::Value, v8::Localv8::Message) [/usr/local/bin/node]
3:
v8::internal::V8::FatalProcessOutOfMemory(char const_, bool)
[/usr/local/bin/node]
4:
v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
5:
v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object__, v8::internal::Isolate_) [/usr/local/bin/node]
6:
0x890dfc079a7
Caught exception:
undefined

Activity

  1. jgw96 commented on Oct 3, 2016

    @jgw96
    Contributor

    Hello @chack would you mind running npm install inside your app and seeing if you still run into this issue? The latest app-scripts includes a fix for this issue.

  2. chack commented on Oct 3, 2016

    @chack
    Author
  3. adamdbradley commented on Oct 3, 2016

    @adamdbradley
    Contributor

    @chack If you don't add the --max-old-space-size=2048 flag, do you still get the errors with the latest app-scripts?

  4. Manduro commented on Oct 4, 2016

    @Manduro
    Contributor

    Ran into this using 0.0.28:

    [13:00:41]  templateUpdate started ...
    [13:00:41]  bundle dev update started ...
    <--- Last few GCs --->
     1419503 ms: Mark-sweep 1262.8 (1438.9) -> 1262.8 (1438.9) MB, 3390.2 / 0.0 ms [allocation failure] [GC in old space requested].
     1422541 ms: Mark-sweep 1262.8 (1438.9) -> 1262.8 (1438.9) MB, 3037.0 / 0.0 ms [allocation failure] [GC in old space requested].
     1425939 ms: Mark-sweep 1262.8 (1438.9) -> 1273.9 (1420.9) MB, 3397.1 / 0.0 ms [last resort gc].
     1429769 ms: Mark-sweep 1273.9 (1420.9) -> 1285.1 (1420.9) MB, 3829.0 / 0.0 ms [last resort gc].
    <--- JS stacktrace --->
    ==== JS stack trace =========================================
    Security context: 0x2c7804cfb51 <JS Object>
        1: decode(aka decode) [/Users/user/etc/etc/etc/node_modules/rollup/dist/rollup.js:~302] [pc=0x33a2e24d8a59] (this=0x2c780404381 <undefined>,mappings=0xbbe3fa04201 <Very long string[3487733]>)
        2: render [/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:8971] [pc=0x33a2e2ce9947] (this=0x3b1e918ab8c1 <a Bundle with map 0x326f83434f9>,options=0x3d04914d2cf9 <a...
    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
     1: node::Abort() [/Users/user/.nvm/versions/node/v6.7.0/bin/node]
     2: 
    node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>)
     [/Users/user/.nvm/versions/node/v6.7.0/bin/node]
     3: 
    v8::internal::V8::FatalProcessOutOfMemory(char const*, bool)
     [/Users/user/.nvm/versions/node/v6.7.0/bin/node]
    
    
     4: 
    v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Users/user/.nvm/versions/node/v6.7.0/bin/node]
     5: 
    v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/user/.nvm/versions/node/v6.7.0/bin/node]
     6: 
    0x33a2e1f079a7
     7: 0x33a2e24d8a59
     8: 0x33a2e2ce9947
    
  5. cmaart commented on Oct 4, 2016

    @cmaart
    Contributor

    Can confirm this as well for 0.0.28

  6. mirkonasato commented on Oct 4, 2016

    @mirkonasato

    To summarise my comments on #85, this patch fixes it for me: https://gist.github.com/mirkonasato/903e039bf341707776c402497afc25bb

  7. shlomiassaf commented on Oct 4, 2016

    @shlomiassaf
    Contributor

    Can confirm this as well for 0.0.28
    Node: v5.11.1

    Error:

    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
    
    <--- Last few GCs --->
      154894 ms: Scavenge 1399.5 (1456.8) -> 1399.5 (1456.8) MB, 3.4 / 0 ms (+ 1.3 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
      156028 ms: Mark-sweep 1399.5 (1456.8) -> 1391.4 (1456.8) MB, 1133.6 / 0 ms (+ 1.3 ms in 1 steps since start of marking, biggest step 1.3 ms) [last resort gc].
      157282 ms: Mark-sweep 1391.4 (1456.8) -> 1393.2 (1456.8) MB, 1253.7 / 0 ms [last resort gc].
    <--- JS stacktrace --->
    ==== JS stack trace =========================================
    Security context: 0x3968415e3ac1 <JS Object>
        1: /* anonymous */(aka /* anonymous */) [/Users/shlomiassaf/Desktop/Cisco/IONIC/ionic-app-scripts/node_modules/rollup/dist/rollup.js:~8365] [pc=0x3e2e6953d3cc] (this=0x396841504189 <undefined>,line=0x181e0e1b6221 <JS Array[12]>)
        2: arguments adaptor frame: 3->1
        3: InnerArrayMap(aka InnerArrayMap) [native array.js:~1019] [pc=0x3e2e69562746] (this=0x396841504189 <undefined>,bl=0x2a2a5...
    

    Happens around the 5th watch code update.

  8. Aristona commented on Oct 5, 2016

    @Aristona

    +1, happens to me too on both 0.0.27 and 0.0.28

    Node 6.7.0

  9. MarkChrisLevy commented on Oct 5, 2016

    @MarkChrisLevy

    Confirm, happens to me as well on 0.0.28.

    <--- Last few GCs --->
      895072 ms: Mark-sweep 1262.1 (1434.8) -> 1262.1 (1434.8) MB, 2272.5 / 0 ms [allocation failure] [GC in old space requested].
      897233 ms: Mark-sweep 1262.1 (1434.8) -> 1262.1 (1434.8) MB, 2160.5 / 0 ms [allocation failure] [GC in old space requested].
      899376 ms: Mark-sweep 1262.1 (1434.8) -> 1262.1 (1434.8) MB, 2142.9 / 0 ms [last resort gc].
      901505 ms: Mark-sweep 1262.1 (1434.8) -> 1262.1 (1434.8) MB, 2129.6 / 0 ms [last resort gc].
    <--- JS stacktrace --->
    ==== JS stack trace =========================================
        2: arguments adaptor frame: 3->1
    Security context: 0x1211394c9e31 <JS Object>
        3: InnerArrayForEach(aka InnerArrayForEach) [native array.js:~946] [pc=0x2f36080ade5f] (this=0x121139404189 <undefined>,br=0x4e5424eb219 <JS Function (SharedFunctionInfo 0x16aeb3e86159)>,bs=0x121139404189 <undefined>,w=0x3dfa49eba651 <JS Array[22]>,x=22)
        4: forEach [native array.js:~956] [pc=0x2f36080e262c] (this=0x3dfa49eba651 <JS Array[22]>,br=0x4e...
    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
     1: node::Abort() [/usr/local/bin/node]
     2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
     3: 
    v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
     4: 
    v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
    
     5: 
    v8::internal::FullCodeGenerator::PopulateDeoptimizationData(v8::internal::Handle<v8::internal::Code>) [/usr/local/bin/node]
     6: 
    v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*) [/usr/local/bin/node]
     7: 
    v8::internal::Compiler::EnsureDeoptimizationSupport(v8::internal::CompilationInfo*) [/usr/local/bin/node]
     8: 
    v8::internal::OptimizedCompileJob::CreateGraph() [/usr/local/bin/node]
     9: 
    v8::internal::Compiler::GetOptimizedCode(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ConcurrencyMode, v8::internal::BailoutId, v8::internal::JavaScriptFrame*)
     [/usr/local/bin/node]
    10: 
    v8::internal::(anonymous namespace)::CompileOptimized(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ConcurrencyMode) [/usr/local/bin/node]
    11: 
    v8::internal::Runtime_CompileOptimized_Concurrent(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
    12: 0x2f360520961b
    
  10. UISTRepo commented on Oct 5, 2016

    @UISTRepo

    +1

  11. MarkChrisLevy commented on Oct 5, 2016

    @MarkChrisLevy

    @adamdbradley Does the flag --max-old-space-size=2048 should help ionic serve to avoid out of memory? If yes, then unfortunately out of memory error is still there, no change with that flag.

  12. chack commented on Oct 5, 2016

    @chack
    Author

    @lleevvyy yes it does, see my comment above

  13. MarkChrisLevy commented on Oct 5, 2016

    @MarkChrisLevy

    @chack Ok, thanks.

  14. chack commented on Oct 5, 2016

    @chack
    Author

    @lleevvyy for clarification: you have to paste it into the package.json as is wrote in the comment and not as flag in the terminal. Then you can clearly see the benefit. If you run serve too long it will get the error still sometimes :( but a lot less!

  15. 18 remaining items

  16. RyanMcDonald commented on Oct 7, 2016

    @RyanMcDonald

    Same issue here with broken interfaces. Downgraded to 0.0.28 in the meantime.

  17. jgw96 commented on Oct 12, 2016

    @jgw96
    Contributor

    Hello all! I am going to close this issue for now as this specific memory issue has been fixed in v0.0.30. Just for full disclosure, there is another memory issue that is being actively worked on, and that 0.0.31 should go towards fixing. Thanks everyone!

  18. nnixaa commented on Nov 9, 2016

    @nnixaa

    Hey @jgw96, still seeing this, can't really find steps to reproduce it - happens accidentally after some changes in the code while running ionic serve:

    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
    
    <--- Last few GCs --->
    
      544163 ms: Mark-sweep 1386.9 (1457.0) -> 1392.3 (1457.0) MB, 1335.4 / 0 ms [allocation failure] [GC in old space requested].
      545503 ms: Mark-sweep 1392.3 (1457.0) -> 1392.3 (1457.0) MB, 1339.8 / 0 ms [allocation failure] [GC in old space requested].
      546834 ms: Mark-sweep 1392.3 (1457.0) -> 1384.5 (1457.0) MB, 1330.6 / 0 ms [last resort gc].
      548148 ms: Mark-sweep 1384.5 (1457.0) -> 1386.5 (1457.0) MB, 1313.8 / 0 ms [last resort gc].
    
    
    <--- JS stacktrace --->
    
    ==== JS stack trace =========================================
    
    Security context: 0x126a479e3ac1 <JS Object>
        1: findDeclaration [/Users/nixa/Development/Projects/ProjectName/node_modules/rollup/dist/rollup.js:~5359] [pc=0x2fc2c0755ed4] (this=0x3a23996ea6d1 <a Scope with map 0x300771ab0b61>,name=0x126a4795e3f9 <String[1]: i>)
        2: bind [/Users/nixa/Development/Projects/ProjectName/node_modules/rollup/dist/rollup.js:6516] [pc=0x2fc2c34eb124] (this=0x3435a6aae4f9 <a Node wit...
    

    my env is:

    Your system information:
    
    Cordova CLI: 6.3.1
    Gulp version:  CLI version 1.2.1
    Gulp local:
    Ionic Framework Version: 2.0.0-rc.2
    Ionic CLI Version: 2.1.4
    Ionic App Lib Version: 2.1.2
    Ionic App Scripts Version: 0.0.41
    ios-deploy version: 1.9.0
    ios-sim version: 5.0.10
    OS: Mac OS X El Capitan
    Node Version: v5.11.0
    Xcode version: Xcode 8.0 Build version 8A218a
    
  19. shreekantha commented on Mar 17, 2017

    @shreekantha

    Hey @jgw96 I am also facing the same issue.

    Below is the my package.json

    {
    "name": "dhI",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.7",
    "ionic-angular": "2.1.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "ng2-googlechart": "^2.1.0",
    "rxjs": "5.0.0-beta.12",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.6.26"
    },
    "devDependencies": {
    "@ionic/app-scripts": "1.1.3",
    "typescript": "2.0.10"
    },
    "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard",
    "cordova-plugin-statusbar"
    ],
    "cordovaPlatforms": [],
    "description": "dhI: An Ionic project"
    }

  20. timothybclayton commented on Jul 7, 2017

    @timothybclayton

    I've was able to workaround this issue on Ionic v3.5, Ionic cli 3.4.0, and Node.js 6.9.1. We have a big app with lots of modules and heap space errors occurring every build, whether "ionic serve", or "ionic cordova run --prod".

    Modify your ionic.cmd file in C:\Users<user>\AppData\Roaming\npm by adding --max_old_space_size. I set mine to 8096.

    @if EXIST "%~dp0\node.exe" (
    "%~dp0\node.exe" --max_old_space_size=8048 "%~dp0\node_modules\ionic\bin\ionic" %*
    ) ELSE (
    @SETLOCAL
    @set PATHEXT=%PATHEXT:;.JS;=;%
    node --max_old_space_size=8048 "%~dp0\node_modules\ionic\bin\ionic" %*
    )

    Good luck!

  21. phonic commented on Aug 11, 2017

    @phonic

    @timothybclayton You've saved my friday. Thanks a lot!

  22. bkarv commented on Oct 20, 2017

    @bkarv

    Does anyone know how to increase the node memory in OSX?

  23. manicloudlogic commented on Nov 21, 2017

    @manicloudlogic

    Thanks it's working

  24. bigthing33 commented on Feb 8, 2018

    @bigthing33

    Does anyone know how to increase the node memory in OSX?

  25. bkarv commented on Feb 8, 2018

    @bkarv

    @bigthing33 hey mate this worked for me:

    1. Upgrade to Typescript 2.6.1 (or latest) ie npm install typescript@latest

    2. Upgrade Ionic, Ionic Scripts and Ionic CLI TIP: Run 'ionic doctor check' and do the suggested upgrades

    3. Increased my memory for the build by adding this to the package.json to scripts section as a seperate line:
      "ionic:build": "node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build"

    4. In terminal Ran 'npm run ionic:build --prod' It is important you us the exact command, if it is correct the terminal will print something like:
      node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build

    Note if you still have out of memory issues, try increasing the ram further. I currently have it at 12228 as I have a big app. Best of luck!

  26. bicibg commented on May 17, 2018

    @bicibg

    ok how is this still an issue after 2 years. I am still getting this error. I tried what @bkarv said but then i get "#FailureMessage Object: 0x7febe7443950Illegal instruction (core dumped)"
    `cli packages: (/home/bugra/.linuxbrew/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0
    

    global packages:

    cordova (Cordova CLI) : 8.0.0 
    

    local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2
    

    System:

    Android SDK Tools : 26.1.1
    Node              : v10.0.0
    npm               : 5.6.0 
    OS                : Linux 4.4
    

    Environment Variables:

    ANDROID_HOME : /home/bugra/Android/Sdk
    

    Misc:

    backend : legacy
    

    `

  27. khaled-elrifaay commented on Jun 13, 2018

    @khaled-elrifaay

    @timothybclayton how to do it in linux

  28. pascalwhoop commented on Sep 16, 2018

    @pascalwhoop
    Contributor

    also running into this on linux on node 10.9 ionic cli 4.1.2

    [18:10:43]  copy finished in 5.03 s 
    
    <--- Last few GCs --->
    
    [32515:0x5604aa886a70]    26126 ms: Scavenge 1385.7 (1422.9) -> 1385.1 (1423.4) MB, 2.4 / 0.0 ms  (average mu = 0.171, current mu = 0.089) allocation failure 
    [32515:0x5604aa886a70]    26130 ms: Scavenge 1385.9 (1423.4) -> 1385.3 (1423.9) MB, 2.4 / 0.0 ms  (average mu = 0.171, current mu = 0.089) allocation failure 
    [32515:0x5604aa886a70]    26134 ms: Scavenge 1386.1 (1423.9) -> 1385.5 (1424.9) MB, 2.4 / 0.0 ms  (average mu = 0.171, current mu = 0.089) allocation failure 
    
    
    <--- JS stacktrace --->
    
    ==== JS stack trace =========================================
    
        0: ExitFrame [pc: 0xf4c117dc01d]
    Security context: 0x3fe8a951e549 <JSObject>
        1: signatureToSignatureDeclarationHelper(aka signatureToSignatureDeclarationHelper) [0x11a4942fd539] [/home/pascalwhoop/Documents/Code/show-your-boots.org/node_modules/typescript/lib/typescript.js:~26245] [pc=0xf4c12ae9aa5](this=0x2983ca6026f1 <undefined>,signature=0x1326ff9c3ad1 <SignatureObject map = 0xfb048b8ff09>,kind=160,context=0x328bfd49b811 <Objec...
    
    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
     1: 0x5604a7ff9101 node::Abort() [node]
     2: 0x5604a7ff914f  [node]
     3: 0x5604a81bad72 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
     4: 0x5604a81bafcb v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
     5: 0x5604a854f313  [node]
     6: 0x5604a854f454  [node]
     7: 0x5604a855f0d3 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
     8: 0x5604a855fa59 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
     9: 0x5604a8561b6d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
    10: 0x5604a8561bc2 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
    11: 0x5604a852fd65 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node]
    12: 0x5604a87a23ff v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
    13: 0xf4c117dc01d 
    [ERROR] Non-zero exit from subprocess.
    

    when running ionic build --prod --minifyjs --minifycss --optimizejs --engine browser

  29. pascalwhoop commented on Sep 16, 2018

    @pascalwhoop
    Contributor

    can we all agree that the solution to getting a production build with ionic is not to just let some crazy memory leak go all the way to 4-8GB for building a >1MB web application?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions