-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: allow specifying memory limit #3947
Conversation
$memoryLimit = $options['memory-limit']; | ||
|
||
if (!is_scalar($memoryLimit)) { | ||
throw new ConfigException('Invalid memory limit specified.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this case is even possible -- however without the scalar check, psalm complained about the following:
ERROR: PossiblyInvalidCast - src/psalm.php:202:38 - list<mixed> cannot be cast to string (see https://psalm.dev/190)
ini_set('memory_limit', (string) $memoryLimit);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getopt()
will return a list if you specify the option multiple times.
E.g psalm --memory-limit=1 --memory-limit=2
will result in
array(1) {
'memory-limit' =>
array(2) {
[0] =>
string(1) "1"
[1] =>
string(1) "2"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
today I learned!
92d9b5c
to
bee2e3f
Compare
Thanks! |
@muglug how to use this? I tried |
@mshamaseen It appears that it must be specified in bytes ( |
ini_set format should be accepted, a string is a valid scalar. So '1024M' should work. Most probably you have a ini_set('memory_limit') in your own code that gets executed by your autoloader. Could you check if it could be the case? Try with --debug-by-line to try to see where Psalm crash |
@orklah @AndrolGenhald it does not work, it says: vendor/bin/psalm --memory-limit=1073741824 ${CHANGED_FILES}
|
Looks fine to me, have you tried a higher limit? |
should close #3945