Tuesday, 22 May 2007
Memory Use with GD Images in PHP Script |
| |
|
| |
Richard Davey while working on a project noticed some interesting issues regarding Graphics Library (GD) images and the amount of memory they take up when storing them in a PHP script. With this he has also discovered something relating to auto loading classes, which is related to memory allocation.
The scenario, he explains involves loading a JPEG (1024 x 768 pixels in size), create a thumbnail based on that, and output the thumbnail.
During coding he profiled and checked the memory use after each GD operation to see which method had the greatest impact on Random Access Memory (RAM).
The process that the scripts took was extremely simple. It would load a JPEG, create a new thumbnail 200x200 in size and then destroy the original JPEG image resource. While carrying out this procedure, he looked at how much memory was freed-up after calling the imagedestroy() function on the original JPEG.
He lists out the procedure as follows:
- Straight Procedural
- Storing the image resource in an Object array
- Storing the image resource in an Object var
- autoload grief
|
| |
|
Read the Post
|
| |
|
|
| |
|
|
| |
|