Skip to main content
InterviewHubPRO
Section Overview
Q18

Question 18 of 50

Part 2: Zend Engine Internals, OPcache & Memory Architecture (11 - 24)

36%
PHP & Zend Engine (50 Qs)•Part 2: Zend Engine Internals, OPcache & Memory Architecture (11 - 24)

What is a WeakMap in PHP 8 and how does it prevent memory leaks in caching?

senior LevelMost AskedMemory ManagementSystem Design

In Simple Words: A WeakMap holds references to object keys without preventing the Garbage Collector from freeing them. When the object key is destroyed, its corresponding entry in the WeakMap is automatically removed.