WebReference.com has a new sample chapter from Sara Goleman's book "Extending and Embedding PHP" (Chapter 3) taking a look at memory management in PHP.
One of the most jarring differences between a managed language like PHP, and an unmanaged language like C is control over memory pointers.
The chapter looks at:
- Freeing up unneeded resources
- Handling error requests correctly
- An introduction to the Zend Memory Manager
- Counting references to avoid unnecessary copying
- The usefulness of "copy on write"
- Saving resources with "change on write"
- Difficulties with handling seperation of values
Each of the above items is accompanied by a good bit of text and code examples where appropriate (even a diagram or two to make things clearer).