Skip to content

Out of memory errors #4

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

Closed
davidyell opened this issue Feb 22, 2019 · 5 comments
Closed

Out of memory errors #4

davidyell opened this issue Feb 22, 2019 · 5 comments

Comments

@davidyell
Copy link

davidyell commented Feb 22, 2019

Full disclosure: This is my first time trying Docker, after seeing your excellent talk at PHPUK19.

I have run two commands and both have written an out of memory exception to the resulting file.

$ docker run -it --rm -v "$PWD":/app -w /app adamculp/php-code-quality:latest php /usr/local/lib/php-code-quality/vendor/bin/phploc -v --names "*.php" --exclude "vendor" . > ./phploc.txt

Results in a file containing

phploc 4.0.1 by Sebastian Bergmann.

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /usr/local/lib/php-code-quality/vendor/phploc/phploc/src/Analyser.php on line 92

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /usr/local/lib/php-code-quality/vendor/phploc/phploc/src/Analyser.php on line 209

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /usr/local/lib/php-code-quality/vendor/phploc/phploc/src/Analyser.php on line 241

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /usr/local/lib/php-code-quality/vendor/phploc/phploc/src/Analyser.php on line 124

When running the phpcpd command the file results in

phpcpd 2.0.4 by Sebastian Bergmann.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /usr/local/lib/php-code-quality/vendor/sebastian/phpcpd/src/Detector/Strategy/Default.php on line 45

Is this related to my locally installed PHP ini settings? Any guidance would be super. Thanks!

@hackzilla
Copy link

It seems to be a php memory limit as you thought.
You can override the limit by passing in -d memory_limit=1G to php.

e.g.
docker run -it --rm -v "$PWD":/app -w /app adamculp/php-code-quality:latest php -d memory_limit=1G /usr/local/lib/php-code-quality/vendor/bin/phploc -v --names "*.php" --exclude "vendor" .
phploc 4.0.1 by Sebastian Bergmann.

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /usr/local/lib/php-code-quality/vendor/phploc/phploc/src/Analyser.php on line 92

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /usr/local/lib/php-code-quality/vendor/phploc/phploc/src/Analyser.php on line 209

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /usr/local/lib/php-code-quality/vendor/phploc/phploc/src/Analyser.php on line 241
Directories 37

@hackzilla
Copy link

Looking at the Dockerfile, it was set at 512M.

@davidyell
Copy link
Author

Thanks @hackzilla that's worked for me. I wonder if the commands in the readme should be updated to reflect this.

@adamculp
Copy link
Owner

Great idea. Also, I'll be updating to use PHP 7.2 to prevent the 7.3 deprecations that affect PHPLoc.

@adamculp
Copy link
Owner

I added a note to the README for future users to know how to handle memory limit errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants