Practical CS: Memory and Garbage Collection in PHP

Drupal Camp Asheville 2021 Online Edition - July 8th-9th

When & Where

Room
Hopin Sessions
Start Time
July 9, 2021 - 1:00 pm EDT

Topics

Speaker

Speaker
Jim Vomero
Jim Vomero photo
Company

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.

Target Audience

This session is for PHP programmers of all experience levels. The content is written for developers who do not have a computer science background and may be struggling with impostor syndrome.

Learning Objectives

Attendees should leave with some best practices for declaring, scoping, and unsetting variables. They will gain a few tools for measuring performance so they can continue to explore this topic in their own work.

Prior Technical Knowledge

This is for developers who understand the basics of PHP; creating variables, functions, and blocks of code. The goal is to be accessible to all levels of programming but interesting to a wide audience as well.

Video