allocate more memory for powershell?

This topic contains 5 replies, has 2 voices, and was last updated by  js 3 months, 2 weeks ago.

  • Author
    Posts
  • #73933

    js
    Participant

    In general, how would you allocate more memory for powershell?

  • #74080

    Don Jones
    Keymaster

    In general, you would not, because you don't allocate memory for processes on Windows. All processes start with a virtual memory space of around 4GB, and Windows manages that memory space automatically. Windows is much better at managing all the memory demands from moment to moment than a person ;).

  • #74083

    js
    Participant

    I was helping someone on the windows 10 it pro forum that had 60,000 firewall rules in windows 10, but he said powershell would give an error like "not enough space" when he tried to clean it up.

  • #74087

    Don Jones
    Keymaster

    Holy crap. The firewall process itself is probably using half the systems' memory – Windows Firewall was never designed for that kind of rule load. They'd be a lot better off placing firewalls in front of small client segments and letting a dedicated firewall handle that load for the clients. Either than or install 32GB of RAM in those machines.

    That's probably not PowerShell saying "not enough memory" per se; it's probably Windows telling PowerShell "there ain't no more memory, man."

    But still, there's no way to allocate memory to a specific process. Prxocesses get a huge virtual memory space, most of which is served from the page file. Windows decided how much fo the page file gets backed by physical RAM on a moment-to-moment basis; you can't force Windows to allocate physical RAM to a specific process if WIndows doesn't want to. What he needs to do is find out who's eating all the physical RAM, and check to make sure his swap file is appropriately sized for the number of running processes.

    But this is basic Windows memory management; PowerShell itself is just a pawn like every other process in the game.

  • #74089

    Don Jones
    Keymaster

    He could probably mitigate by not trying to "get" all the firewall rules at once. The memory needed for 60k objects is substantial enough that Windows probably can't fulfill it along with whatever else the system is doing. Try to get just a subset of the rules and remove them. Or, use command-line tools other than PowerShell, which has the additional overhead of .NET, garbage collection, and whatnot.

  • #74092

    js
    Participant

    These firewall rules are normal for windows 10. Each user gets about 100 firewall rules. I think it's app related. It's gotten better in 1703.

    So I shouldn't tell him to follow this page (although it has a typo, see last comment)? https://blogs.technet.microsoft.com/heyscriptingguy/2013/07/30/learn-how-to-configure-powershell-memory/

    How come this thread doesn't appear on the main page of powershell.org — recent posts?

You must be logged in to reply to this topic.