• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Running out of RAM

Sorry, TheinsanegamerN but you just underlined the Princess's and my point. You just demonstrated you don't fully understand commit rates or commit limits.

That is NOT a criticism. Just an observation.

Are you a true expert in memory management? Are you a computer scientist? Note I did not ask if you are a programmer or even a hardware tech.

Why is such a commit limit in place? MS requires you to either sacrifice notable storage space just to use your RAM, or face annoying errors like this.
Why is a commit limit in place? Why does the room you are standing in limit the size of the furniture you put in it?

Commit limit = the current page file size + RAM amount. How is Microsoft forcing that limit on you?

And nothing requires you sacrifice your storage space to use your RAM. Total nonsense.

I can use 99% of my system RAM with no swap and no errors.
Yeah. So? That proves nothing.

I left my front door unlocked last night and no one came in. That means it is safe to leave my door unlocked, right? :kookoo:

but why is there no option to get around this?
Huh? Again, you just demonstrated you really don't understand how it works in Windows and you should go with the defaults. Again, not a criticism - just another observation.
 
Sorry, TheinsanegamerN but you just underlined the Princess's and my point. You just demonstrated you don't fully understand commit rates or commit limits.

That is NOT a criticism. Just an observation.

Are you a true expert in memory management? Are you a computer scientist? Note I did not ask if you are a programmer or even a hardware tech.
No, I am not
Why is a commit limit in place? Why does the room you are standing in limit the size of the furniture you put in it?
Right. But if your room has space for 2 chairs and a table, but refuses entrence if you put mroe then a table into the room, THAT doesnt make any sense. That's what MS's commit limit is doing.
Commit limit = the current page file size + RAM amount. How is Microsoft forcing that limit on you?
The Princess demostrated a situation where, with no Swap available, the system was acting like it was out of memory when there was demonstrably plenty of physical RAM not being used. MS forces you to have a page file large enough to hold a hypothetical commit larger then what you are actually using to use your phsyical RAM. This is silly.
And nothing requires you sacrifice your storage space to use your RAM. Total nonsense.
Space slated for swap usage cannot be used to store files. If your swap is not large enough, even if you are not using said swap, windows will not use all your available phsyical RAM. This, demonstrably, requires you to sacrifice storage to use RAM in windows.
Yeah. So? That proves nothing.
It proves that requiring commits larger thent he amount of RAM you are using is unnecessary.
I left my front door unlocked last night and no one came in. That means it is safe to leave my door unlocked, right? :kookoo:
No, but it demonstrates that your risk may be lower then the standard, and if you know what you are doing/are aware of the risks/have your reasons, you dont need Microsoft Door Manager refusing to turn off the lights because your door is unlocked.
Huh? Again, you just demonstrated you really don't understand how it works in Windows and you should go with the defaults. Again, not a criticism - just another observation.
I dont use windows, I use linux. And I dont have these issues.
 
  • Like
Reactions: SL2
I dont use windows, I use linux. And I dont have these issues.
LOL I don't use Linux (anymore). I use Windows. And I don't have these issues.

Moving on.
 
  • Haha
Reactions: SL2
I've installed more than a hundred times ever since W2000, and many times I've done it directly without trying to figure out what's going on, but in the end it always depends on what's wrong.

This time it was different. It pretty much always takes three days before it goes wrong, and I just got too curious to let it go.

Can anyone guess why this code would cause memory leaks in Windows, but only after three days? I'm no expert.. :D The program itself never uses more than 4 MB.

View attachment 323638
I can tell you similar programs exist that do what you are doing without reinventing the wheel.

Look into something like below:

 
  • Like
Reactions: SL2
The memory chugging kicked in today, I checked with poolmon and figured it out. I have the same problem as this one.

When looking for info I saw a lot of dead ends, people who never could figure it out. Here I saw some more info about what to do, although I never got to try it myself.

The cause for this was a small program I made that runs in the background (audio related). I will have a look at it later on, but I'm glad I didn't reinstall! That would have been a waste of time.

I disabled some Startup Event Trace Sessions earlier, do they have to be reactivated?


Thanks everyone for the help!
These massive memory leaks occured for me when using any active microphone and i had Nvbroadcast installed, from any source (the official nvidia app, Icue, LGhub, etc)
Uninstalling those programs did not remove their NV Broadcast addons, and they each used 1GB+ of RAM.

what was this audio program intended to do?
 
Play a soundfile (silence) every tenth second.

I can tell you similar programs exist that do what you are doing without reinventing the wheel.

Look into something like below:

I didn't try to invent anything, just solving a simple problem on my own. Now I keep on working with it just to learn from it.

Thanks for the tip.


If anyone interprets my posts as me bragging about what I've accomplished, well that's not what's going on. I mean, it's like two lines of code lol..
I just wanted some help, and I'm thankful for all the help I've been getting
 
Your rant is appreciated, but it also underlines why so many think they can outdo MS. Why is such a commit limit in place? MS requires you to either sacrifice notable storage space just to use your RAM, or face annoying errors like this. Linux doesnt ahve this issue, and neither did MACos back when you could upgrade. I can use 99% of my system RAM with no swap and no errors. Of course, that should be the default for msot users, but why is there no option to get around this?

It's also brining back bad memories of XP and it's LOVE of swapping as much as possible to pagefile. I do remember making RAMdisks with excess sytem RAM and forcing the pagfile onto them to get around this, but it was something just dumb....
I'm not a memory management expert, so I'll defer to those who are, but to my limited understanding, when something wants to allocate memory, Windows wants to ensure it can promise that memory will always be there if it ever goes to get referenced. From what I understand, Linux (and I suppose MacOS) apparently allow overcommiting to some degree, but I think even they have their limits. And when things run out in those situations, things tend to be even more disastrous. Windows' philosophy seems to be to not allow it to get to that point. Linux seems more "it's on you" about everything because it puts trust and responsibility on you for a lot of things.

As for your statement about having to sacrifice storage space, you don't. The maximum size isn't necessarily the initial size, unless the user sets a large fixed size. The initial size tends to be small, 1/8th the installed RAM amount, and will only grow from there if needed (and the commit limit can grow to intermediate values between these two as well, so it's not an either or). It only takes that space if needed. It's adaptable. And it your workload does grow to claim that space, meaning your workload commits a lot more than it uses, that's not really Windows' fault.

Disabling the page file works if you don't push your RAM, but you're losing access to all of your RAM. If you have more memory than you need, this is a non-issue. I think disabling the page file if you truly have a lot of RAM is fine if you want to assume that risk, but I don't like seeing others suggest they "should" disable or limit it by default. Just beware of running into the issue I did once I started needing more of my memory. Having to double down on RAM to go without a page file wasn't my idea of fun. It merely worked since I didn't need the 16 GB in the first many years I had it.

And I think many of us were just younger and wanting to experiment more back then, but that's just a guess on my part. Windows XP also set a larger initial page file size (times and a half RAM) which may have further led to some of us wanting to cut it back. We were also off the back of Windows 9x and a lot was just different back then.
 
Right. But if your room has space for 2 chairs and a table, but refuses entrence if you put mroe then a table into the room, THAT doesnt make any sense. That's what MS's commit limit is doing.

MS forces you to have a page file large enough to hold a hypothetical commit larger then what you are actually using to use your phsyical RAM.
You just keep demonstrating you don't understand how it works.

You can't knock down the walls of that room to make more space. So, if the room holds 2 chairs and a table, then that "IS" what the commit limit allows. So here you complain the space is not big enough (or the doorman won't let you in - which is just wrong). That said, and once again, Microsoft wisely made the setting dynamic. So if you try to squeeze in a bigger table - guess what? Windows will dynamically increase the PF size, thus increasing the commit limit.

But then you complain the page file is taking up too much room. You can't make up your mind.

I dont use windows, I use linux. And I dont have these issues.
And it shows.

For the record (as seen in my System Specs) this system has 32GB of RAM installed. Here is a screen shot showing how my Windows managed PF is hogging massive amounts of my disk space. :rolleyes:

my PF settings.JPG


Anyway, this has nothing to do with the OP's apparent memory leak. So this time, for real, I am moving on.
 
1701624077911.png
1701623993091.png

The page file itself is only about 2.4 GBs on my system and according to System Informer, my system is actively using about 548 MBs of the page file with a peak usage of 594 MBs. The page file will always remain with a size of 2.4 GBs with a majority of that page file being empty space or filled with null data.

In fact, if we go to the Powershell prompt and execute "ls -Hidden" it will show this...
1701624568795.png

Note the "-a-hs" in the Mode column for pagefile.sys, that indicates that the file is marked as a sparse file meaning that although Windows Explorer and Powershell displays the file size of pagefile.sys as 2.38 GBs, because most of the file is filled with null data, the system only stores non-null data. To understand more about this concept, see... Sparse file - Wikipedia.
 
I didn't try to invent anything, just solving a simple problem on my own. Now I keep on working with it just to learn from it.

Thanks for the tip.


If anyone interprets my posts as me bragging about what I've accomplished, well that's not what's going on. I mean, it's like two lines of code lol..
I just wanted some help, and I'm thankful for all the help I've been getting
Oh no that's not how you came across at all, no worries.
 
  • Like
Reactions: SL2
That's not how it works. Like I said, RAM usage won't budge for three days, and after that it increases by about 6 GB per hour. I have had task manager open on a separate display, keeping a close eye on it.
The leak kicked in yesterday like predicted. When I left home the paged pool was about 500 MB, and when I came home an hour later it was 6,2 GB, and I could see it go up with about 100 MB at a time. Non-paged had gone up to about 1 GB too. This is totally expected behavior based on what I ve seen before.

No, only using this:
Code:
using System;
using System.Media;
using System.Threading.Tasks;

I dunno, like I said before, I'm sceptical about Thread.Sleep().

___________________________________________________________

Currently I'm running with a 1 second delay (down from 10), just to see if the problem kicks in earlier. My bet is no, but I'm only 9 hours in so it's to early to tell.
So I ran your code as is, and noted the memory usage at different interval -
Before start -
1701648356811.png

20 minutes in -
1701648391855.png

30 minutes in -
1701648408000.png

40 minutes in -
1701648425649.png

50 minutes in -
1701649175119.png

1 hour and done -
1701648491774.png

I can see the memory usage indeed goes up, in 1 hour it used up 15MB. This is the expected behavior as I have said, every Task.Run is going to allocate memory, and since this is an infinite loop, there is no garbage collection performed until the the program exits. By extrapolating the calculation, if you keep the program running all the time (without shutting down or rebooting your PC), it may use up 360MB in 1 day. I don't remember how many days went by before your PC ran out of memory, but you can do that math.
Also, installing System.Windows.Extensions nuget package is required for me. I don't know what you want your program to do, but you can try to put the thread to sleep instead of Task.Run, or perhaps you you can take your question over to Stackoverflow and there are many people that will help you, or better yet, try ChatGPT or Bard to help you with coding the program if you specify your requirements and problem clearly.
 

Attachments

  • 1701648464609.png
    1701648464609.png
    72.8 KB · Views: 58
If there's any driver I suspect it's Nvidia, I've had problems with it on this one and changed the driver before. On the other hand, since the issue persisted after a driver change, maybe it's something else causing this.
Bingo for my system.

After I updated to 21H2 I noticed some weird memory utilisation issues on my system. One of them I already had on 1809 but wasnt a leak (was just high fresh boot utilisation). The other post upgrade was a leak that increased with system uptime.

Did lots of testing, the commit would keep going up yet all diagnostic tools like task manager, process hacker, and rammap would show the ram as free unused memory and all userland processes with low utilisation.

Then I decided to deliberately restart my nvidia driver (mimic what happens on a driver crash). Boom the memory leak went away. This explained why I didnt have the problem with my testing as that was using the iGPU.

I then installed my GT 1030 on my 9900k currently being used for testing, immediately after installing Nvidia driver the on boot high memory usage showed up (so now I know thats Nvidia also), and left it running idle for days and days, and sure enough it was leaking also, fresh install of windows.

I am going to try out this poolmon tool it has peaked my interest.

Using the igpu as primary desktop GPU prevents the leaking which is nice as thats my plan for this system, but the high boot up usage appears simply from installing the driver. The Nvidia driver is also causing very high commit to physical ram usage ratio as well. Some crazy stuff.

My theory as to why 1809 was ok is 21H2 has more system processes utilising GPU acceleration. (textinputhost and searchapp).

The sooner I get iGPU as my desktop GPU permanently the better.
 
Last edited:
So I ran your code as is, and noted the memory usage at different interval -
Thanks for trying out the code! What I'm most interested in is what happens on day three. I've tried to explain two times already that that something else is happening at that point.

What you're showing doesn't explain the memory usage after 72 hours. Looking at the paged pool alone, it would take 2266 hours going from ~0.5 GB to 33.8 GB with a rate of 15 MB/h. Instead, it takes a few hours after day three.

1701655847427.png

As for VS, I don't have any packages installed here, which makes me wonder why you have to.
1701656351814.png
 
Play a soundfile (silence) every tenth second.
Why? That seems so pointless. There must be a reason. Isn't silence otherwise constantly "playing"?
 
I read three pages where you seem to try your hardest not to explain it. Where did you explain it?

Well, have fun! I am sure there is a better way to do whatever you are trying to do, but that doesn't seem to be your objective.

I would start by asking why you are doing what you are doing. Then I would ask if there is a better way. Whatever weird bug requires you to break the existing silence every 10 seconds in order to play silence, must have a better solution.

Isn't this something you could easily "solve" with Windows Task Scheduler? And probably more efficiently. I think the real solution would be to solve the problem which makes you have to do this in the first place.
 
Last edited:
  • Like
Reactions: SL2
I read three pages where you seem to try your hardest not to explain it.
Nope, you're the second person who ask.
Well, have fun! I am sure there is a better way to do whatever you are trying to do, but that doesn't seem to be your objective.
My objective, like I said, is right now to learn how this works. From the beginning it was to find the memory leak, as I had no clue it was this program that caused it. I suspected some driver, and I wasn't the only one.

I would start by asking why you are doing what you are doing.
Well, you've read all of it so you should know. ;)

I didn't try to invent anything, just solving a simple problem on my own. Now I keep on working with it just to learn from it.


Isn't this something you could easily "solve" with Windows Task Scheduler?
Way ahead of you. But you've already read it so this isn't news for you. :roll:
I'm going to set longer intervals, and if that affects how long it takes until the problem comes back then I'll start focusing on my program.
I will also replace SoundPlayer with MediaPlayer and see if that changes anything. Or set the task scheduler to start it every x second instead of looping it.
 
Thanks for trying out the code! What I'm most interested in is what happens on day three. I've tried to explain two times already that that something else is happening at that point.

What you're showing doesn't explain the memory usage after 72 hours. Looking at the paged pool alone, it would take 2266 hours going from ~0.5 GB to 33.8 GB with a rate of 15 MB/h. Instead, it takes a few hours after day three.

View attachment 324068
As for VS, I don't have any packages installed here, which makes me wonder why you have to.
View attachment 324069
I don't know why or how the page pool works that way and frankly, as a developer, I am more concerned with writing the proper code and once that is done, the problem should resolve itself. Anyway, I tried this line to replace your Task.Run and I don't see memory growing anymore. Perhaps this will work for whatever purpose that you need..
C#:
Thread.Sleep(TimeSpan.FromSeconds(interval));
Start -
1701664686157.png

I went to have dinner and came back 2 hours later -
1701664714312.png

I am not sure why there is a drop in memory usage, perhaps some garbage collection from the previous run. Oh by the way, after running the code with playing a sound for hours, my headphone started to give a cackle noise whenever I watch YouTube. I am going to reboot my computer and hopefully the problem will go away.
 

Attachments

  • 1701664705578.png
    1701664705578.png
    95.4 KB · Views: 48
  • Like
Reactions: SL2
I don't know why or how the page pool works that way and frankly, as a developer, I am more concerned with writing the proper code and once that is done, the problem should resolve itself. Anyway, I tried this line to replace your Task.Run and I don't see memory growing anymore. Perhaps this will work for whatever purpose that you need..
C#:
Thread.Sleep(TimeSpan.FromSeconds(interval));
Thank you. As my code doesn't have any asynchronous tasks running anymore I have no use for Task.Run.

The reason for why I didn't see Task.Run as a problem was that memory usage kept climbing even with Thread.Sleep.

I see you don't post memory usage images from VS, you use Task manager instead. Is there any reason for that?

Here I'm running with Thread.Sleep, although sped up to 10 ms delays. Process memory is climbing, heap is not.
1701671144362.png

The thing is that if I remore sp.PlaySync() and only loop Thread.Sleep then memory stays flat.

This makes me believe that SoundPlayer is indeed not fit for this kind of work, and that old post might still hold true.
 
Last edited:
Thank you. As my code doesn't have any asynchronous tasks running anymore I have no use for Task.Run.

The reason for why I didn't see Task.Run as a problem was that memory usage kept climbing even with Thread.Sleep.

I see you don't post memory usage images from VS, you use Task manager instead. Is there any reason for that?

Here I'm running with Thread.Sleep, although sped up to 10 ms delays. Process memory is climbing, heap is not.
View attachment 324083
The thing is that if I remore sp.PlaySync() and only loop Thread.Sleep then memory stays flat.

This makes me believe that SoundPlayer is indeed not fit for this kind of work, and that old post might still hold true.
No particular reason other than I just ran it instead of debug. Debug will take up more memory because there are other libraries loaded for debug. The best way to monitor is to build it as EXE and run it that way.

I don't know much about SoundPlayer so you will have to figure out the best way for your use case.
 
  • Like
Reactions: SL2
I didn't try to invent anything, just solving a simple problem on my own. Now I keep on working with it just to learn from it.

Thanks for the tip.


If anyone interprets my posts as me bragging about what I've accomplished, well that's not what's going on. I mean, it's like two lines of code lol..
I just wanted some help, and I'm thankful for all the help I've been getting
Nothing wrong with bragging about writing two lines of code, if it solved a problem

It caused a new one, but that's literally every programming joke ever.
 
My BT connection causes crackling noises when no audio is played.
If I was shot with a gun, I would go to a doctor and get them to patch me up.

You'd stick a sex toy in the bullet hole, then complain it's caused the wound to get infected and now your family members have to care for you.

Fix the actual problem in a sane way - like, IDK, switching out the problematic BT hardware - instead of coming up with an objectively insane "solution" that not only does not fix it, but causes more problems for other people like us. "If it's stupid but it works, it's not stupid" is not always true.
 
Thank you. As my code doesn't have any asynchronous tasks running anymore I have no use for Task.Run.

The reason for why I didn't see Task.Run as a problem was that memory usage kept climbing even with Thread.Sleep.
Have you tried using PlayLooping() instead and just never stopping it. Might sidestep your problem as well. The only other thing I see is that t doesn't really need to be a variable. A constant or just using a literal should be fine.
As to no rising memory usage if PlaySync is removed: are you compiling on debug or release? On release I wouldn't be surprised if the compiler just optimizes the entire loop away since it only sleeps at that point.
 
  • Like
Reactions: SL2
Back
Top