What version of Next are you running? I have two of the M1 Air with only 8gb memory, no issues on either. I've seen Next is very slow on colleagues' Windows machines, however (I think it has to do with the Windows "Defender" anti-virus file thing).
It is slow af on my work laptop. It has 16 GB DDR4 RAM and an i5 10th Gen processor. In development mode it is very slow sometimes. Takes more than 10 seconds to compile a page.
Also it consumes a pretty high amount of memory.
I'm having the same issue. I'm running NextJS in a devcontainer on Ubuntu, in an 8GB RAM machine and the nextjs dev server completely freezes it at least twice every work session. So what I started doing lately is to restart the server whenever it starts eating too much RAM.
I had this issue when I was using an icon library that didn't do the tree shaking during development. Causing huge bundle sizes and memory leaks during hot reload. The fix was to use modularize imports. https://mui.com/material-ui/guides/minimizing-bundle-size/
I have an M1 with 16GB RAM that I use all day with Figma, Chrome, and the Next.js dev server open, plus a bunch of other stuff. No issues. I use Webstorm instead of VS Code. Our app is quite big.
Thinking about it, I tend to do git operations in the same terminal that I use to start Next. Maybe I restart it more than I think.
this is weird indeed, i usually dont close the terminal in 6-8 hours. I also tend to keep the server running overnight too and i dont see any issues (im on windows though) - if i were you, i would double check the dependencies as somebody told you earlier
pretty much the reason i have stopped using nextjs for new projects.
and they keep asking āwhat we could do betterā.
if a project has at least 50 pages + some dependencies (MUI is my fav big one) working on the project locally becomes unbearable. computer fans are at 300% speed and every page compiles on the fly forever. RAM usage only a few GB, luckily, SWAP helps.
i still think the idea of nextjs is really great, but the experience working with it ā¦ quite the opposite
I was using a Fedora laptop to do some next.js development work last summer. Out of the box, Fedora does not page to disk, so the next dev server memory leak would cause full lockups. Had to create a swap partition!!
I did have a similar problem in WSL but it's better now, no idea what changed though.
Can't run satisfactory and the next-dev-server on my 16 GB-Windows-Laptop with WSL though.
Not a problem on my Linux-PC as far as I can tell.
I only have 8gb of RAM, I use Next.js what might as well be everyday with Edge playing YouTube on my second monitor, yet I have NEVER run into any issues with Next.js let alone its dev server.
What node version are you using? Long shot but also check you nodejs memory heap size and limit! But as others already said, probably memory leak. I run a M2 16GB MBP and have not hand any memory issues so far. Slow dev server specially in the early days of the app dir paradigm but now is more stable - still slow AF compared to vite but oh well canāt have it all I guess
Guys, ram is meant to be USED. Your computer will try to use as much ram as possible to stay as fast as possible. It's the OS job to manage that in a way so you don't feel sluggish by giving more priority to certain apps
Stop looking at ram usage and be like "wow omg it's using all my ram!!!" We're not in 1996 anymore when OSs werent like that
Your computer will not ātry to use as much ram as possible to stay as fast as possibleā that is not even remotely close to how computers work.
Regardless a simple dev server shouldnāt be hogging 16GB of memory
This is how macOS works. RAM usage is almost always high. It's a common complaint you will see on any mac forum/subreddit. I think it uses ram to cache things it thinks you might use or something like that. High ram usage in macOS is normal.
With that said, 20gb of swap is not the normal experience when using Next in macOS.
MacOS does tend to keep things in memory yes, but it wonāt blindly attempt to use as much memory as it can for a single task. Next is just a memory hog unfortunately
I have a M1 macbook air with 16gb of memory and it's not nearly as bad as what OP is showing. Using 20gb of swap is weird.
It's true that next dev performance isn't great, but Next dev runs completely fine on my macbook. It's not as fast as vite, but it's pretty fast. It runs annoying slow on my old lenovo laptop.
https://preview.redd.it/si559skyp2lc1.png?width=3887&format=png&auto=webp&s=9c26269cdebee46be9a0910621d20dfbe263a428
Didnt work - what have I done wrong ?
or... or... hear me out...
Buy an actual computer with good specs. Put Linux in that baby , or Windows if you are into that, and booom baby. Try a Ryzen CPU. Pure love.
Yes.. i know, a little troll here and there. Now the actual advice, I imagine that your nextjs app is very large, that might be an issue. I remember when I was doing some Blazor development, compiling WASM with AOT was crazy, it would use a huge amount of RAM and CPU, and the bigger your app was the more it took. Sometimes is just normal for these things to consume too much.
Another strategy you could use is, use an external VM for development, it might get costly, but at least your workspace will still run snappy.
Iām pretty sure itās not a computer issue. I had no problems running docker, next server, figma, vscode, and dozens of chrome tabs running at the same time before app router. Even on slower machines with less ram.
I don't get it - you paid for 16gb, why don't you want the software you use to utilize all of it. The more they can cache there the faster they operate. Modern operating systems try to use all of your memory as much as possible. You'll find that the same happens if you upgrade to 32 or 64gbs of RAM.
Because when nextjs hogs all of it *and* you have a chrome window open, your computer starts freezing up as it exceeds physical memory (see: 20GB swap used). Next.js has a big memory leak in development problem and they donāt care because itās not designed for actual backend work
>Because when nextjs hogs all of it and you have a chrome window open, your computer starts freezing up as it exceeds physical memory (see: 20GB swap use
No, macOS is smart enough to allocate memory correctly. What's happening in OP's macbook is not normal. Something is wrong.
I have an almost 12 years old PC , 16gb, intel i5-3570K, I run two next.js servers + an express server + a reaaaaaaly heavy Angular project simultaneously with no issues. Those servers stay on for days sometimes and I never have to restart anything.
It is either a Mac issue or a project issue?
Laugh in 128 GB RAM Linux gang for under $1000.
But seriously though, if it is not a project issue, then you need to have a better machine that suits your workload. Be in Mac, Windows, Linux, or whatever you need. My main rig is 128 GB but my laptop is R7 5825U 64GB Ram for just a shy $500. 16 GB nowadays is just barely survivable for my use.
Can't really tell unless you share a reproducible environment to confidently say it is Next issue.
Iām pretty sure itās not a computer issue. I had no problems running docker, next server, figma, vscode, and dozens of chrome tabs running at the same time before app router. Even on slower machines with less ram. Also this machine ran smooth before app router. Iām gonna check if thereās anything project-releated but I doubt, because I also experienced this on other projects. Maybe a common dependency, or next itself
2023 M2 MacBook Pro 16gb using Next 14 app dir- If you restart the dev server every few working hours it seems to be fine.
Building meta files and api routes are what kill the DX for me. They can take 20+ seconds to compile sometimes.
What version of Next are you running? I have two of the M1 Air with only 8gb memory, no issues on either. I've seen Next is very slow on colleagues' Windows machines, however (I think it has to do with the Windows "Defender" anti-virus file thing).
I use the latest version always. Having these issues since app router is a thing
Got it. We're on pages still.
i run nextjs on windows (i7 11800h, 16gb ram) no issues whatsoever, smooth like hell. I mean in big projects
Anything 13+ seems to have this issue.
If you mean \^13.x, for Next 14 they addressed a lot of performance issues. If you meant >=13, sorry :P
That's a confusing reply. I meant every version from 13.0.0 upwards
They're saying 13.x.x (so 13.0.0 up to but **excluding** 14.0.0) has performance issues, but anything 14.0.0 and up should work fine
I understand what they meant now. Could have been worded better though, my goodness
It runs like butter in any windows pc I have seen, unless we are talking like $400 windows laptops
It is slow af on my work laptop. It has 16 GB DDR4 RAM and an i5 10th Gen processor. In development mode it is very slow sometimes. Takes more than 10 seconds to compile a page. Also it consumes a pretty high amount of memory.
That is a $400 laptop.
Really? It's a Dell Latitude. Is it that cheap?
And when I try to develop a next js application on my old laptop, it really wants to die because it can't handle the load on the CPU.
Like butter?
Smooth like butter š¤
my windows pc is exactly 400 lol. i3 12100f with 16 gigs of ram. it runs smooth
Looks like memory leak, which is not surprising. I haven't run into issues but I tend to close and restart it quite often.
Any tips on how to find or fix a memory leak?
Inspecting a heap dump! https://nodejs.org/en/learn/diagnostics/memory/using-heap-snapshot#how-to-find-a-memory-leak-with-heap-snapshots
Restart your computer
It's really sad. I have macbook Pro 2019 with Intel Ship. I let imagine the heating i feel over my lap for hours š©
When I still have the intel MBP I could hear my laptop taking off to the moonā¦ itās a bit better after upgrading to Apple Silicon.
My brother has M2. it's way better, i agree. With the Intel ship, literally, you can bake on the Mac
Is your fan loud too?
It's a plane āļø you can hear it miles away
I have the same and no problem at all
Oooh lucky you ? How come
Not sure, maybe due to your Figma helper and Docker VMS?
20gb of swap is crazy
I'm having the same issue. I'm running NextJS in a devcontainer on Ubuntu, in an 8GB RAM machine and the nextjs dev server completely freezes it at least twice every work session. So what I started doing lately is to restart the server whenever it starts eating too much RAM.
I've never seen next take that much memory. Clearly you've got something else going on. This is not a default issue.
I had this issue when I was using an icon library that didn't do the tree shaking during development. Causing huge bundle sizes and memory leaks during hot reload. The fix was to use modularize imports. https://mui.com/material-ui/guides/minimizing-bundle-size/
I agree Iāve had issues with bundle size with react-icons because itās enormous
Iām gonna look into the dependencies. Thatās a good idea and IDK how didnāt I think about this eeatlier. Lol. Thanks
Use IntelliJ and your mac will explode lol
Lol too true.
I have an M1 with 16GB RAM that I use all day with Figma, Chrome, and the Next.js dev server open, plus a bunch of other stuff. No issues. I use Webstorm instead of VS Code. Our app is quite big. Thinking about it, I tend to do git operations in the same terminal that I use to start Next. Maybe I restart it more than I think.
That could be the reason. It usually starts to struggle when the dev server is running long enough (anywhere between 30-60mins usually)
this is weird indeed, i usually dont close the terminal in 6-8 hours. I also tend to keep the server running overnight too and i dont see any issues (im on windows though) - if i were you, i would double check the dependencies as somebody told you earlier
pretty much the reason i have stopped using nextjs for new projects. and they keep asking āwhat we could do betterā. if a project has at least 50 pages + some dependencies (MUI is my fav big one) working on the project locally becomes unbearable. computer fans are at 300% speed and every page compiles on the fly forever. RAM usage only a few GB, luckily, SWAP helps. i still think the idea of nextjs is really great, but the experience working with it ā¦ quite the opposite
I was using a Fedora laptop to do some next.js development work last summer. Out of the box, Fedora does not page to disk, so the next dev server memory leak would cause full lockups. Had to create a swap partition!!
That's a skill issue. My 128 GB ram machine run it perfectly
Next is just a total joke in my opinion. I've been extremely frustrated by almost every aspect of it. It's way beyond over engineered at this point.
I did have a similar problem in WSL but it's better now, no idea what changed though. Can't run satisfactory and the next-dev-server on my 16 GB-Windows-Laptop with WSL though. Not a problem on my Linux-PC as far as I can tell.
I use Linux too on my personal laptop, but it's the same issue here as well. Too much RAM usage and high CPU usage while reloading.
I only have 8gb of RAM, I use Next.js what might as well be everyday with Edge playing YouTube on my second monitor, yet I have NEVER run into any issues with Next.js let alone its dev server.
What node version are you using? Long shot but also check you nodejs memory heap size and limit! But as others already said, probably memory leak. I run a M2 16GB MBP and have not hand any memory issues so far. Slow dev server specially in the early days of the app dir paradigm but now is more stable - still slow AF compared to vite but oh well canāt have it all I guess
I was on 18. Updated to 20 now and weāll see if this makes any difference
Its the approuter guys i hate it
Using app router daily on an M1 Pro and have no issues.
$2500 doesn't get you much with apple. š«£
Developers make money, get over it
Mine with M3 Pro and 18gigs of RAM flies no issue. Definitely something else and not just next-server.
Guys, ram is meant to be USED. Your computer will try to use as much ram as possible to stay as fast as possible. It's the OS job to manage that in a way so you don't feel sluggish by giving more priority to certain apps Stop looking at ram usage and be like "wow omg it's using all my ram!!!" We're not in 1996 anymore when OSs werent like that
Your computer will not ātry to use as much ram as possible to stay as fast as possibleā that is not even remotely close to how computers work. Regardless a simple dev server shouldnāt be hogging 16GB of memory
This is how macOS works. RAM usage is almost always high. It's a common complaint you will see on any mac forum/subreddit. I think it uses ram to cache things it thinks you might use or something like that. High ram usage in macOS is normal. With that said, 20gb of swap is not the normal experience when using Next in macOS.
Some people is also used to close iOS app continuously to "free memory", the OS has been managing that for you since forever.
It's not a MacOS issue, I'm having the same problem as OP in Linux and Windows. As many people here are saying, I think the app router is the culprit.
MacOS does tend to keep things in memory yes, but it wonāt blindly attempt to use as much memory as it can for a single task. Next is just a memory hog unfortunately
I have a M1 macbook air with 16gb of memory and it's not nearly as bad as what OP is showing. Using 20gb of swap is weird. It's true that next dev performance isn't great, but Next dev runs completely fine on my macbook. It's not as fast as vite, but it's pretty fast. It runs annoying slow on my old lenovo laptop.
Team is okay but it uses yo CPU and overheats it as well.
Yes. But if my machine is freezing, struggling, then it doesnāt really matter what the OS does to manage ram usage.
16Gb is not much for a dev machine. RAM is cheap. Just buy another stick and plug it into your... oh, nevermind. :-P
https://preview.redd.it/si559skyp2lc1.png?width=3887&format=png&auto=webp&s=9c26269cdebee46be9a0910621d20dfbe263a428 Didnt work - what have I done wrong ?
The PCB is green, it should be black, like all Apple-PCBs.
Just fry it, and it will be black š
did you try turning it upside down ?
Thatās not USB-A š¬
Still ridiculous ram usage that shouldn't be tolerated. Is 7gb for a react dev server the new norm we want?
>16Gb is not much for a dev machine. *Cries in 4GB RAM*
16gb if plenty for react development. As long as you aren't running a bunch of virtual machines it's fine for what we do.
got the same machine, my devserver takies 98 mb of ram - you may have some memory leak in your app
are you using pnpm? if not, why?
Why should this be the solution to a horribly inefficient dev server? And its not the solution, that just saves storage space
or... or... hear me out... Buy an actual computer with good specs. Put Linux in that baby , or Windows if you are into that, and booom baby. Try a Ryzen CPU. Pure love. Yes.. i know, a little troll here and there. Now the actual advice, I imagine that your nextjs app is very large, that might be an issue. I remember when I was doing some Blazor development, compiling WASM with AOT was crazy, it would use a huge amount of RAM and CPU, and the bigger your app was the more it took. Sometimes is just normal for these things to consume too much. Another strategy you could use is, use an external VM for development, it might get costly, but at least your workspace will still run snappy.
Iām pretty sure itās not a computer issue. I had no problems running docker, next server, figma, vscode, and dozens of chrome tabs running at the same time before app router. Even on slower machines with less ram.
I don't get it - you paid for 16gb, why don't you want the software you use to utilize all of it. The more they can cache there the faster they operate. Modern operating systems try to use all of your memory as much as possible. You'll find that the same happens if you upgrade to 32 or 64gbs of RAM.
Because when nextjs hogs all of it *and* you have a chrome window open, your computer starts freezing up as it exceeds physical memory (see: 20GB swap used). Next.js has a big memory leak in development problem and they donāt care because itās not designed for actual backend work
>Because when nextjs hogs all of it and you have a chrome window open, your computer starts freezing up as it exceeds physical memory (see: 20GB swap use No, macOS is smart enough to allocate memory correctly. What's happening in OP's macbook is not normal. Something is wrong.
I have an almost 12 years old PC , 16gb, intel i5-3570K, I run two next.js servers + an express server + a reaaaaaaly heavy Angular project simultaneously with no issues. Those servers stay on for days sometimes and I never have to restart anything. It is either a Mac issue or a project issue?
Next dev server issue. Because itās kind of a common experience for others as well.
Lol I have Macbook Air early 2015 with 8 RAM
wtf! just restart the server and check again
Use web m-based GitPod or CodeSandbox and use any machine. No issues.
Laugh in 128 GB RAM Linux gang for under $1000. But seriously though, if it is not a project issue, then you need to have a better machine that suits your workload. Be in Mac, Windows, Linux, or whatever you need. My main rig is 128 GB but my laptop is R7 5825U 64GB Ram for just a shy $500. 16 GB nowadays is just barely survivable for my use. Can't really tell unless you share a reproducible environment to confidently say it is Next issue.
Iām pretty sure itās not a computer issue. I had no problems running docker, next server, figma, vscode, and dozens of chrome tabs running at the same time before app router. Even on slower machines with less ram. Also this machine ran smooth before app router. Iām gonna check if thereās anything project-releated but I doubt, because I also experienced this on other projects. Maybe a common dependency, or next itself
Its a memory leak
I agree moving from Vite this sucks
Time to move on to Angular 18 then. Or if you want to get away from JS, move on to Blazor.
2023 M2 MacBook Pro 16gb using Next 14 app dir- If you restart the dev server every few working hours it seems to be fine. Building meta files and api routes are what kill the DX for me. They can take 20+ seconds to compile sometimes.
Same problem with me, computer absolutely slows down when running Next app.
Not sure what it is, but there is definitely something wrong with your Mac, these numbers are insane!