Index
- Installation
- Getting Started
- Memory Usage
- Readers and Writers
- The Document Class
- Metadata
- Pages
- Canvas
- Page Layout and Mode
- Viewer Preferences
- Document Outline
- Page Labels
- Actions
- Destinations
- Annotations
- Embedded File Streams
- Colors and Color Spaces
- Page Formats and Boundaries
- Standard and Public Key Encryption
- Fonts and Encodings
- Corrupted Documents
- Reader Enabled Documents
- Migrating
- API Reference
Memory Usage Things you need to know about memory usage and management
Table of Contents
Introduction
The SetaPDF components make heavy use of passing objects to other objects for observing or other purposes which ends in cycled references between the objects.
By doing this there are cycled references created which has to be collected by the garbage collection logic of PHP.
Common Memory Management
To allow the Garbage Collection to clean up the cycled references it is a requirement that no variable points to the related object in a specific variable scope.
To gain the full benefit of the Garbage Collection it is a prefered way to encapsulate memory intensive task into method/function scope. This way the Garbage Collection can clean up the references when the scope is left and it is not needed to unset the variables manually.
Following PHP code shows the behavior:
By default, PHP's garbage collector is turned on. There is, however, a php.ini setting that allows you to change this: zend.enable_gc.
More information about PHP's garbade collector and how to control its behavior can be found here.