Hey,
re: limiting factor I don't completely disagree but then again, in
most cases, it's possible to design the app in a way which resolves
the problem.
As to weak references, you could do weak references in PHP just by
using the indirect property access. Might not be perfect but it's quite doable.
Andi
At 09:21 PM 12/8/2005, Alan Pinstein wrote:
Generally speaking, if you create a circular reference (whether by
reference or by value), then you will have a "memory leak" until
the end of the request. This is not only true for objects (and
circular references might be indirect) but also for arrays.
sure, of course...
This is a side-effect of reference counting systems, but within the
way PHP is used within a request/response paradigm, it shouldn't be
a real limiting factor in real-life usage.
Well I'd say that using a PHP-CLI script to import bulk data is a
real-life usage and this is definitely a limiting factor. Do you
disagree?
On the contrary, for these kind of apps, garbage collecting systems
have potential to be significantly slower.
Well, Cocoa solves the problem in a manner I consider quite graceful.
In 99% of situations, you don't touch memory management and things
work themselves out like in PHP. However, there is a concept of a
WEAK REFERENCE (a non-ref-counted ptr to the object) that is used
*specifically* in these cases to prevent circular references.
With this type of system, there is no additional overhead because the
GC doesn't have to "detect" circular references and determine if the
objects are orphaned but deadlocked... instead this is a situation
left to the developer to manage.
Now I understand that PHP isn't Obj-C and it's a higher-level
language and that's fine.
However, my question, which still remains unanswered, is that I've
found a way that "seems" to create a weak reference and I'm simply
asking if what I am doing is condoned or just lucky (and thus a bad
idea that will probably break in the future)...
And, if it's just lucky, then what is the solution to the problem? Am
I just SOL? Is the answer simply that if you *need* to create
circular references in PHP, then you *must* accept memory leakage?
Alan
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php