# PHP Object-Caching and Reference Counting

- Thread: https://externals.io/message/27563
- Original archive: https://news-web.php.net/php.internals/27563
- Started by Lars Schultz on 2007-01-21T16:21:07+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #27563 — Lars Schultz — 2007-01-21T16:21:07+00:00

URL: https://externals.io/message/27563#27563

> Note that the engine does not guarantee you any particular value of 
> the refcount. Passing parameters around, accessing variables, etc. may 
> change the refcount. One thing the engine guarantees you is that once 
> no links to the variable exist it would be destroyed (which may not 
> happen immediately after you do unset, for example, but probably would 
> happen "soon"). So actually figuring out if the object is referenced 
> by any other place could prove non-trivial, depending on the 
> application structure.


I don't understand the problem really, because I am aware that even a 
parameter counts as a reference (why not?)...it wouldn't matter in my 
case because I am in total control of the last two references...so if 
there are more, I keep it. Tracking the references manually is not 
really an option because it's such a large project.

I don't understand the part about the engine not guaranteeing the 
destruction immediately. Because as soon as the ref-count decreases to 
zero it can be removed from memory...it's different in java and other 
languages which don't use ref-count but more complex algorithms like 
mark-and-sweep and such, they only are run once in a while and may not 
be triggered manually...so, I'd understand it in that case.
