Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Derick Rethans' Blog:
Collecting Garbage: Cleaning Up
Sep 07, 2010 @ 14:56:25

Derick Rethans has continued his series on garbage collection in the PHP internals with this second post of the series with a special look at circular references. You can find the first part here.

In this second part of the three part column on the new garbage collecting mechanism in PHP 5.3, we'll dive into a solution to the problem with circular references. If we look quickly back, we found that by using code like the [first example], an in-request memory leak is created.

He goes on to briefly describe the synchronous algorithm (including a few more helpful graphs to show the flow) and how that has worked its way into the PHP garbage collection methods. He also points out that this collection can be turned off and on via the gc_enable and gc_disable functions. Keep an eye out for the next part of the series where he gets into more detail on how this is all integrated into PHP.

tagged: garabage collection article phparchitect circular references

Link:

Alex Netkachov's Blog:
Optimize PHP memory usage: eliminate circular references
Sep 18, 2007 @ 22:17:21

On his blog today, Alex Netkachov has posted a suggestion of how to combat a common issue facing PHP scripts - their memory usage.

PHP has a build-in garbage collector so you do not need to track the links on the objects, allocate memory for objects and delete them when they are not longer necessary. Things seem so perfect that developers do not even know that their scripts allocate a lot of memory until their server stops processing requests because of the out of memory error.

His example is the processing of a parent/child relationship tree. If not managed correctly, the variables being used could get out of hand quite quickly. Alex recommends the use of a "destructor" at the end of each iteration to help destroy variables and values no longer needed.

tagged: optimize memory circular reference destructor variable optimize memory circular reference destructor variable

Link:

Alex Netkachov's Blog:
Optimize PHP memory usage: eliminate circular references
Sep 18, 2007 @ 22:17:21

On his blog today, Alex Netkachov has posted a suggestion of how to combat a common issue facing PHP scripts - their memory usage.

PHP has a build-in garbage collector so you do not need to track the links on the objects, allocate memory for objects and delete them when they are not longer necessary. Things seem so perfect that developers do not even know that their scripts allocate a lot of memory until their server stops processing requests because of the out of memory error.

His example is the processing of a parent/child relationship tree. If not managed correctly, the variables being used could get out of hand quite quickly. Alex recommends the use of a "destructor" at the end of each iteration to help destroy variables and values no longer needed.

tagged: optimize memory circular reference destructor variable optimize memory circular reference destructor variable

Link:

Derick Rethans' Blog:
Circular References
Jun 26, 2007 @ 14:21:00

In a new post, Derick Rethans talks about circular references (a reference of a memory structure back to itself) and how they relate to PHP.

Circular-references has been a long outstanding issue with PHP. They are caused by the fact that PHP uses a reference counted memory allocation mechanism for its internal variables. This causes problems for longer running scripts (such as an Application Server or the eZ Components test-suite) as the memory is not freed until the end of the request. But not everybody is aware on what exactly the problem is, so here is a small introduction to circular references in PHP.

He starts by explaining what's so bad about circular references - issues not only with referencing the variable but also with freeing up the resources associated with it. He does suggest some solutions to the issue including garbage collection and cyclic tracing.

tagged: circular reference garbagecollection cyclictracing circular reference garbagecollection cyclictracing

Link:

Derick Rethans' Blog:
Circular References
Jun 26, 2007 @ 14:21:00

In a new post, Derick Rethans talks about circular references (a reference of a memory structure back to itself) and how they relate to PHP.

Circular-references has been a long outstanding issue with PHP. They are caused by the fact that PHP uses a reference counted memory allocation mechanism for its internal variables. This causes problems for longer running scripts (such as an Application Server or the eZ Components test-suite) as the memory is not freed until the end of the request. But not everybody is aware on what exactly the problem is, so here is a small introduction to circular references in PHP.

He starts by explaining what's so bad about circular references - issues not only with referencing the variable but also with freeing up the resources associated with it. He does suggest some solutions to the issue including garbage collection and cyclic tracing.

tagged: circular reference garbagecollection cyclictracing circular reference garbagecollection cyclictracing

Link:


Trending Topics: