Powershell: Support for $MaximumFunctionCount and other limits should be removed

Created on 10 Sep 2016  路  3Comments  路  Source: PowerShell/PowerShell

We should consider removing the following variables:

PS> gv Max*Count

Name                           Value
----                           -----
MaximumAliasCount              4096
MaximumDriveCount              4096
MaximumErrorCount              256
MaximumFunctionCount           4096
MaximumHistoryCount            4096
MaximumVariableCount           4096

They don't really protect the user from anything (it's easy to use up memory in many other ways) and they block some valid uses, e.g. if you add > 4096 functions in InitialSessionState, the extra functions will be silently ignored - and there is no good way to increase that limit until after the runspace is open.

Issue-Bug WG-Engine WG-Language

Most helpful comment

It's a very good idea.

I have some doubts about removing MaximumErrorCount. It is very different
from the others and some limit makes sense. There may be a lot of errors in
some cases. This is bad for long running processes. Developers must keep
in mind that memory may leak via errors and care of this. Why?

Besides, when errors really have to be collected and analysed then use of
-ErrorVariable parameter for a particular command is better than use of
$Error which also may contain noise errors. -ErrorVariable is unlimited.

All 3 comments

Agreed. I'd much rather see a consolidated "reporting" command that tells me how many of each I have (even better if it could display memory foot print). In case I need to debug a situation where too much memory is used for/by something. But even without that, yeah I'd be fine with removing these.

It's a very good idea.

I have some doubts about removing MaximumErrorCount. It is very different
from the others and some limit makes sense. There may be a lot of errors in
some cases. This is bad for long running processes. Developers must keep
in mind that memory may leak via errors and care of this. Why?

Besides, when errors really have to be collected and analysed then use of
-ErrorVariable parameter for a particular command is better than use of
$Error which also may contain noise errors. -ErrorVariable is unlimited.

Removing the max value variable doesn't mean the error collection couldn't still be capped at a max size of 256. I guess the question in this case is - does anybody ever change (increase) that value? I can't say that I have ever done that in 10+ years of using PowerShell.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garegin16 picture garegin16  路  3Comments

alx9r picture alx9r  路  3Comments

JohnLBevan picture JohnLBevan  路  3Comments

rudolfvesely picture rudolfvesely  路  3Comments

concentrateddon picture concentrateddon  路  3Comments