Skip to main content
InterviewHubPRO
Section Overview
Q26

Question 26 of 50

Part 3: Production Tuning, Asynchronous Workers & High Scale (25 - 35)

52%
PHP & Zend Engine (50 Qs)•Part 3: Production Tuning, Asynchronous Workers & High Scale (25 - 35)

How do you detect and diagnose memory leaks in long-running PHP CLI workers?

senior LevelCLIAsync & PromisesMemory Management

In Simple Words: Because PHP was designed to discard memory after each web request, long-running CLI daemons (queue workers) frequently suffer from memory leaks caused by unbounded static collections and event listener registrations.

Prevention:

  • Track usage with memory_get_usage(true).
  • Regularly cycle worker processes after processing $N$ jobs.