Psalm: Huge memory consumption on dev branch

Created on 10 Jul 2020  路  9Comments  路  Source: vimeo/psalm

I just updated Psalm to the last dev version today and Psalm doesn't run anymore with the 8Gb memory it has.

The error is
PHP Fatal error: Allowed memory size of 8589934592 bytes exhausted (tried to allocate 1912606720 bytes) in C:\Users\rmorin\Documents\PhpstormProjects\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\Statements\Expression\AssertionFinder.php on line 144

This seems related to the fix for https://github.com/vimeo/psalm/issues/3631

Most helpful comment

Oh well that's obvious, Psalm can't read French.

All 9 comments

Hey @orklah, can you reproduce the issue on https://psalm.dev ?

Can you narrow this down to an individual file by running with --debug?

Can you narrow this down to an individual file by running with --debug?

I did, The file is around 1700 lines but I nothing really particular for our codebase. I tried running only this file and it fails too (with a failed allocation of 2.8G).
Anything specific I should look for? What does this code do? I tried putting the file on psalm.dev but it fails because it's too big(I think). If I remove some comments, it shows error due to missing dependancies

Anything specific I should look for?

Yeah, try removing stuff (methods and/or method bodies) from the file until it doesn't fail anymore

Somehow, it's caused by a big ball of chained assignations:
$code_defaut_signale = $defaut_signale = $code_defaut_signale_cli = $defaut_signale_cli = $operateur_reno = $batiment_reno = $operateur_condi = $operateur_qualite = $batiment_qualite = $operateur_mad = $batiment_mad = $date_expe = $heure_expe = $operateur_expe = $batiment_expe = $operateur_retrofit = $batiment_retrofit = $resultat_retrofit = $operateur_soft = $batiment_soft = $operateur_pretest = $batiment_pretest = $resultat_pretest = $operateur_foudre = $batiment_foudre = $resultat_foudre = $operateur_dielec = $batiment_dielec = $resultat_dielec = $batiment_condi = $code_panne = $etape_panne = $code_panne = $operateur_saisie = $batiment_saisie = $accessoires_saisis = $aspect_saisie = $rejet_garantie = $type_depannage_transfert = $sn_saisie = $sn_cosmetic = '';

When I remove this, it's ok, when it's back, the analysis takes a long time and fails with memory issue

I reproduce with a smaller chain:

                $code_defaut_signale = $defaut_signale = $code_defaut_signale_cli = $defaut_signale_cli =
                $operateur_reno = $batiment_reno = $operateur_condi = $operateur_qualite = $batiment_qualite =
                $operateur_mad = $batiment_mad = $date_expe = $heure_expe = $operateur_expe = $batiment_expe =
                $operateur_retrofit = $batiment_retrofit = $resultat_retrofit = $operateur_soft = $batiment_soft =
                $operateur_pretest = $batiment_pretest = $resultat_pretest = $operateur_foudre = $batiment_foudre =
                $resultat_foudre = $operateur_dielec = $batiment_dielec = $resultat_dielec = '';

But after that, when I try to remove one of the variables, it seems to suddenly work (I tried removing 2-3 different variable to see if it was a specific variable that caused it, but it doesn't seem so)

Reproducible on psalm.dev: https://psalm.dev/r/b909e38485

Oh well that's obvious, Psalm can't read French.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings