[wp-trac] [WordPress Trac] #11780: Memory Leak in plugins_api

WordPress Trac wp-trac at lists.automattic.com
Tue Feb 16 09:11:36 UTC 2010


#11780: Memory Leak in plugins_api
--------------------------+-------------------------------------------------
 Reporter:  hakre         |        Owner:          
     Type:  defect (bug)  |       Status:  reopened
 Priority:  normal        |    Milestone:          
Component:  General       |      Version:  3.0     
 Severity:  normal        |   Resolution:          
 Keywords:  needs-patch   |  
--------------------------+-------------------------------------------------

Comment(by dd32):

 hakre: That link also specifically mentions this:

 {{{
 Do not use return-by-reference to increase performance. The engine will
 automatically optimize this on its own. Only return references when you
 have a valid technical reason to do so.
 }}}

 What miqrogroove is saying, is that PHP doesnt "return by reference" in
 the C++ sense of the word.

 http://au.php.net/features.gc.refcounting-basics is a good reference to
 how PHP stores variables, and why returning by reference is not needed to
 reduce memory footprint. It'll also explain how Objects can cause memory
 leaks in the Garbage collection unit (Note to self: Glass can break
 through thin bags).

 PHP5 takes it a step furthur once again, Objects are not stored in the
 same bucket as variables, in addition to being passed as reference in all
 case and as such, returning them as reference under php5 is even more
 useless.

 So, Returning a simple variable from the function will not cause memory
 leaks, nor can this create a memory leak due to serialization not handling
 circuar references (IIRC).

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11780#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list