Skip to content
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

Fix used memory reporting #2686

Merged
merged 1 commit into from
Oct 18, 2023
Merged

Fix used memory reporting #2686

merged 1 commit into from
Oct 18, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Oct 18, 2023

while observing memory consumption of PHPStan I noticed a difference between what PHPStan reports as "used memory" and what the operating system resource monitor reports.

especially in the last few seconds of the phpstan run, I noticed a climb in the very end, which was not at all reflected.

running php phpstan analyse -c myphpstan.neon.dist -vvv --debug on my example projects

... before this PR ends in

...
C:\dvl\Workspace\motiontm\models\_Images.php
--- consumed 0 B, total 624 MB, took 0.00 s
C:\dvl\Workspace\motiontm\public\partner\index.php
--- consumed 0 B, total 624 MB, took 0.00 s
Result cache is saved.

 [OK] No errors

Used memory: 624 MB

the end-memory result seems identical with what was reported in the last "consumed"-line. the consumption itself is pretty accurate while running but only a climb up to ~690 at the very end is missing.


After this PR I am taking the memory-peak of the master process into account right before printing the message.
With this change I am now getting something like

...
--- consumed 0 B, total 624 MB, took 0.00 s
C:\dvl\Workspace\motiontm\public\partner\index.php
--- consumed 0 B, total 624 MB, took 0.00 s
Result cache is saved.

 [OK] No errors

Used memory: 692 MB

which matches pretty good what I am getting from the operating system.
note the difference between the "used memory" metric and the one of the last "consumed" line

@staabm staabm marked this pull request as ready for review October 18, 2023 10:50
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit da8c7f9 into phpstan:1.10.x Oct 18, 2023
417 of 419 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the mem-print branch October 18, 2023 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants