SoFunction
Updated on 2025-04-08

angular memory overflow problem solved

This project is built with angular4 and uses dynamic components to display the page. I have encountered the problem of not being able to aot due to memory overflow.

Solution: Manually rewrite the memory limit

Modify the directory: my-project/node_modules/.bin Found:

@IF EXIST "%~dp0\" (
 "%~dp0\" --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
) ELSE (
 @SETLOCAL
 @SET PATHEXT=%PATHEXT:;.JS;=;%
 node --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
)

Modify the directory: my-project/node_modules/.bin  Found:

@IF EXIST "%~dp0\" (
 "%~dp0\" --max_old_space_size=8192 "%~dp0\..\._@[email protected]@@angular\compiler-cli\src\" %*
) ELSE (
 @SETLOCAL
 @SET PATHEXT=%PATHEXT:;.JS;=;%
 node --max_old_space_size=8192 "%~dp0\..\._@[email protected]@@angular\compiler-cli\src\" %*
)

As for what exactly causes the memory overflow, it is not clear, but there are some guesses as follows:

1) Too many files;

2) The subscription data does not destroy the memory (I read the subscription data, which should not be);

3) Because all components are in the same root directory (as mentioned above, the dynamic components used are not used for routing), there are too many components that need to be compiled?

It is not clear yet that I can only solve the problem by setting the memory upper limit first. If there is a great master, I would like to give me some advice;

Another problem is that using dynamic components, all components are in the root directory, which will cause the first loading time to be too long. If you have any ideas, please tell me, haha

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.