Opened 17 years ago
Closed 17 years ago
#4709 closed enhancement (fixed)
Free up memory by using imagedestroy() in wp_create_thumbnail()
Reported by: | Viper007Bond | Owned by: | |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.3 |
Component: | Optimization | Keywords: | |
Focuses: | Cc: |
Description
I noticed that wp_create_thumbnail()
(and possibly other image handling functions) doesn't make use of imagedestroy()
to destroy the temporary image that's in memory once it's done with it.
While this is automatically done when the PHP file is done running, I think it'd be good to do it ourselves as soon as we're done with $thumbnail
, i.e. as soon as we save it.
Less memory usage == good, right? Or am I a noob and missing something?
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
The thumbnail takes up almost no memory. If you want to really free up memory, you should do imagedestroy($image) immediately after the call to imagecopyresampled. $image is the full sized image which was loaded into memory, the resulting $thumbnail is tiny by comparison.
While all this is likely unnecessary, I agree that it's a good idea for the wp_create_thumbnail functions to cleanup after themselves a bit better, since it's possible that plugins and/or other code may attempt to use these directly. WordPress doesn't need this code itself in most cases, but it won't hurt anything to have it there and it might help reduce some people's out-of-memory issues.