-
Notifications
You must be signed in to change notification settings - Fork 12k
webpack ng serve runs out of memory #1652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am thinking about a good way to test this. I already have a little stress test program that generates a working program with a given number of components. But unfortunately it also generates the exact same program each time. So I'm thinking about making it slightly randomize the contents of the programs it generates so that it generates changed files each time. Then run it in a loop and see how much RAM leaks. |
OK, I made a way to test this. I enhanced the "angular 2 stress test" tool: https://www.npmjs.com/package/angular2-stress-test To stress test "ng serve":
In my testing as above:
This shows that ng serve keep using more RAM over time, as it keeps recompiling after each change. However, offhand I would guess that reducing this increase, is pretty far down the priority list of the CLI team! |
I'm interested in whether anyone plays with this, with various settings, modes (-prod ?), platforms (windows linux mac) etc. |
@kylecordes I believe that this could be related to So I think the first thing I will need to do is find instances of us in our codebase using the webpack |
I think that if this is happening on just plain default We separated the idea of I think in terms of |
@slubowsky @kylecordes I did a little hands on memory profiling and heapshot analysis. (I couldn't do it locally so @hansl helped me). Long story short things were either pointing towards the Compilation or some TS Services retaining some objects after Garbage collection was occuring. Luckily we just merged in a kind contribution in webpack that fixes a V8 bug causing memory leaks in the webpack compilation. I believe that this is what is causing the issue, however I think it warrents still following up after we cut a release (on the webpack team), and update it here. https://github.com/webpack/webpack/pull/2497/files |
@TheLarkInn Thanks, sounds good. I will repeat the tests I described earlier in the thread, when the next new release comes out... or for that matter anyone else could try it also. |
Any word on this? I just migrated from beta.10 to beta.15 and I am unable to
Not sure if this has anything to do with it but I also got the following error while
I am on node 4.x and unable to proceed. |
@TheLarkInn @kylecordes @hansl Any help would be appreciated. |
@mithun-daa We have a team of people using CLI-webpack-edition here, and have helped numerous others get it up and running. We have noticed that it consumes quite a bit of memory which grows over time - the topic of this issue, but when we run on good development hardware it is very little practical problem. We just end up restarting CLI every couple of hours, no big deal. I think maybe the error you experience might be unrelated to the general issue here of leakage over time. A quick way to check and help provide more information for the CLI team to work from, is to simply try the exact same thing again on a machine with abundant RAM. |
@kylecordes I wouldn't call my dev machine weak. These specs, I guess should be good enough: |
Right, that is obviously more than ample RAM. So I don't think the problem you are experiencing has anything to do with the somewhat exaggerated RAM usage and leakage over time that CLI+webpack currently experiences. I think you there some other problem in your project. I suggest making a copy of your project, then incrementally trim away nearly all of it until you have a minimum reproduction case for the failure, something which you can publish to a public repository. That will then be a solid bug report which it is likely someone could reproduce and fix. Or you might find that by trimming away pieces you eventually find the bit which triggers this problem, also a great outcome. Good luck. |
@mithun-daa You can raise the heap size using |
@hansl will this work on Windows? Get the following error:
|
@mithun-daa Oh on windows you have to replace |
i did try with the |
mmmh, then I'm not sure. It seems like this is a problem with Node that using a full path doesn't work. On my VM using |
Are there any prereqs? I am on Node 4.2.3. The global version of TS is different from the local version. |
Not really. Node 4.2 should work. I'm seeing a different error on my side but similar reason, with Node 6 on Windows 10. |
@hansl If i create a new project using |
@xnnkmd It's about 10K LOC of Will try after making the changes. I have a feeling that what @tariknz said #1652 (comment) is the root cause of this. It seems that during the compilation, there was an error and memory leak because of it. |
Just as a heads up. It turns out when I use YARN instead of NPM to RESTORE packages ng build completes successfully. I am using
When I restore packages using npm install -- same error from this issue (out of memory) |
Thanks @basherr!
then run "npm run build-prod" |
@RicTheThird and @basherr - worked for me, thanks. |
@RicTheThird - thx. works for me. o/ By the way, i preferred changing the start script rather than adding a new one. |
"scripts": { |
In my case problem was solved after force adding |
I've tried building project with latest webpack till date(i.e. @3.8.1) and it solved the similar issue for me. |
npm uninstall -g @angular/cli and reinstall @angular/cli@1.2.6 solved my problem |
I had experienced the issue You can add also in package.json as
|
Hi, in my case, none of the solutions above worked for me. |
Thanks @rejayi-experion Modifying NG.cmd didn't work but just invoking it manually as you suggested did. |
I mean, is there a reasonable explanation why it takes minutes to compile HTML, TS, and (S)CSS? |
Anyone have a more definitive solution for this? Anyone comment that @TheLarkInn is working in the issue. There is another thread open to this issue? |
node --max_old_space_size=2048 ./node_modules/.bin/ng Worked for me thanks |
For anyone that might be trying to debug why all of a sudden the build process started running out of memory, I was able to track the issue down to the following code in my project. Before change (out of memory exception):
After change (no memory issues):
Using the code of the before change, every time that method was called, it caused more and more memory being used during Not sure why specifying the return type fixes the issue, but went from |
@thecheeto Did you add this modification to every function within your project? And even if it returns void? |
@vitor-belim No, only on that function. I'm thinking it has something to do with differing return types in a function. In my case it was returning either an |
This has been changed in angular 7 now. I couldn't able to find the path of ng.. Please any help for finding its path in node modules.. `> node --max_old_space_size=5048 ng build --prod --aot --source-map=false module.js:540 Error: Error: Cannot find module '/Users/work/ui/node_modules/@angular/cli/bin/ng' npm ERR! A complete log of this run can be found in: npm ERR! A complete log of this run can be found in: |
@prudhvichitturi |
this worked for me:
|
this is simple and fuction for me :3 |
It's weird that I have to tell Angular CLI/Node.js how much memory it can use. Chrome/V8 seems happy to use all my memory. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Windows 10
ng --version
. If there's nothing outputted, please runin a Terminal:
node --version
and paste the result here:angular-cli: 1.0.0-beta.11-webpack.2
node: 6.3.1
os: win32 x64
do on your code? etc.
Keep ng serve running and serving a cli built app while coding for some time (a few hours?)
more information.
Only happened once so far but thought it worth mentioning
The text was updated successfully, but these errors were encountered: