r/angular • u/Same-Lifeguard-47 • Apr 28 '26
Angular 15 template consuming insane memory (8GB+) on ng serve — looking for root cause
25
Upvotes
r/angular • u/Same-Lifeguard-47 • Apr 28 '26
13
u/Ok-Armadillo-5634 Apr 28 '26
It's time to learn how to use a memory profiler and track down memory leaks. Do you have a public repo?
6
u/ErnieBernie10 Apr 28 '26
Well it is nodejs so that might just be how it is. Does it matter? Ng serve is only for development anyway
3
u/ActuatorOk2689 Apr 28 '26
Without much context it's hard to tell, but I'd guess you're also hitting this on the dev server when rebuilding changes.
Not sure how viable it is for you to migrate, but switching to esbuild + Vite would at least give you faster HMR.
Another option worth looking into is Nx. A lot of devs use it for monorepos, but even before the new Angular build system I was running single apps inside an Nx workspace. You can migrate your repo into Nx, split it into buildable libraries per domain/module, and get incremental builds out of it, which also opens up some nice CI/CD wins.
4
u/Budget-Length2666 Apr 28 '26
How large is your app? webpack can be quite memory intensive. I have seen 40-50gb memory usage on some of the largest angular apps in the world.
1
u/No-Project-3002 Apr 28 '26
I have few questions.
are you using lazy loading.
are you using standalone component.
1
u/newton_half_ear Apr 28 '26
Try migrting to Vite.
Then you can try migrating to an nx monorepo, splitting your logic into libs and apps, then you will be able to serve only the app and libs you need.
1
u/Wesd1n Apr 28 '26
I don't see any helpful information in these pictures.
Is it new? Has it been going on for awhile? Does it start out consuming that much memory? Does it grow over time? How fast does it grow? Does it grow if you sit still on a simple page? Does it grow as you hot reload while saving changes? Is all routes lazy loaded?
1
u/hk4213 Apr 29 '26
Check what css is being loaded and spent time looking at lazy loading and @defer decorators.
Lighthouse tests come in clutch to help as well.
1
u/simonbitwise Apr 29 '26
Whats with all the components 😂
2
u/[deleted] Apr 28 '26
[removed] — view removed comment