PowerShell Memory

Hi Experts,

I’ve been wondering about how memory works in PowerShell and was hoping someone can share their insight on the topic.

  • when should we consider changing the default memory size?
  • what are the considerations that go into making a decision?
  • is there any general practice involved if the memory size requires to change due to buggy snapins?
  • what potential components can be impacted if memory size is changed?

Any feedback is always appreciated.

Reference: Learn How to Configure PowerShell Memory - Scripting Blog

That’s actually adjusting memory size for Remoting endpoints, not your local shell. Personally, I’ve not run into a situation where I needed to adjust it. Certainly, if you were running commands that used enormous data sets, and were running out of memory, you might need to give it a bump - and that isn’t a “consideration,” it’s, “oh, we ran out of memory.” It’s not a technique you’d use to somehow combat a buggy module. Apart from old snapins (not modules) that are wrappers around COM objects (like the Quest snapin mentioned in that article’s comments), you’re probably not going to run into memory leaks much.

Personally, I’ve never needed to do this. Just because you can, doesn’t mean you often need to. I’d leave it alone unless you know you’re getting memory-bound on something (KNOW, not guess), and then bump the memory appropriately. Or rewrite your command/script so that it doesn’t need so much memory.