Drush crashes after "command dispatch complete" I have a custom drush script.
This script loads, changes and saves ~10000 drupal commerce products.

After that I get the message

Command dispatch complete [1140.43 sec, 663.25 МБ]                                                                                                                                                                                 [notice]
 Timer                Cum (sec)  Count  Avg (msec) 
 page                 1140.368   1      1140367.61 
 drupal_http_request  67.66      1032   65.562 
Peak memory usage was 784.48 МБ [1140.43 sec, 663.24 МБ]


And AFTER that script hangs and consumes more and more memory.
Finally, after long time, script reaches 1.5 G memory limit and dies.

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 80 bytes) in /var/www/vhosts/mysite.ru/htdocs/sites/all/modules/contrib/entity/includes/entity.wrapper.inc on line 302

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 80 bytes) in /var/www/vhosts/mysite.ru/htdocs/sites/all/modules/contrib/entity/includes/entity.wrapper.inc on line 302


All products which were processed by the script are sucessfully changed.

The question: why drush script hangs when dispatch is complete and what it makes for such a long time when all products are processed?
Is it sort of a post-processing?

Denis
Drush is running out of memory.

In the case of re/indexing search data via Search API, the item in that issue queue for this is Better memory usage on indexing.

To work around these sorts of issues, you can increase the amount of memory used by Drush, without touching the memory limit used by your Web server.  See Configuring php.ini for details.

In my case, in my drush.ini, I increased it from:


memory_limit = 256M


to:


memory_limit = 512M


...and it solved my Search API (re)indexing problem.