Asp Net Core 2.0: resolve error CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory

This is the easiest way to solve this error if someone is using Asp.net Core, Angular, Webpack (AngularTemplateProject)

Expert Code Blog

This error is caused by a memory leak problem of node.js.

On a Visual Studio 2017 Asp Net Core 2.0 project started from the Angular CLI Template, that use WebPack to manage the build process, after some publish builds, due to file size increase, we can get this error:

node node_modules/webpack/bin/webpack.js --env.prod
EXEC(0,0): Error : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

To resolve this error we need to expand the memory size used by node.js.

This is possible setting the max_old_space_size parameter on the node command line with the [size] expressed in bytes:

--max_old_space_size=[size]

But how can we set this value into the publish process.

This is possible changing the .csproj file in this way:

  • Open the .csproj of the project that we are publishing.
  • Find the PublishRunWebpack target.
  • Set the value on each Exec Command which refers to node.
  • Save the changes.

For example, if we…

View original post 95 more words

Leave a comment