Practical CS: Memory and Garbage Collection in PHP

It’s easy to forget that our programs actually run on metal; where ones and zeros are stored as charges in physical components. Modern programming languages give us a false feeling of separation from these circuit boards. Interpreted languages like PHP offer such flexibility, we often don’t consider the low-level issues, such as how our code affects memory allocation.

This beginner session explores computer science topics related to memory in PHP through practical examples. The goal is to demystify memory allocation so that we can write more efficient scripts. Topics include:

- The basics: What is memory and where is it allocated in the PHP lifecycle?
- Dynamic types: How ZVals allow us to change a string to an array to a boolean; and the costs associated with this flexibility.
- Simple benchmarking: How to capture memory metrics without installing large frameworks or profiling tools.
- Memory leaks: A look at garbage collection in PHP and how to reduce the memory consumption of our scripts.

As processors become faster, the way we use memory can be one of the greatest factors slowing down our program execution. Attendees should leave this session with a better understanding of how memory works and feel empowered to reduce their memory footprint.

https://www.drupalasheville.com/2021/session/practical-cs-memory-and-garbage-collection-php

Drupal is a registered trademark of Dries Buytaert.