circular references

php.internals

Wojtek Meler

23 years ago
When you run: <? $a=array(); $b[]=&$a; $a[]=&$b; ?> You will get warnings about memory leaks. I know that it is ugly code etc. but shouldn't it be solved by ZE? It should free such things properly. I know that in this simple case whole memory is freed, but if we add resource to $a table, resource desctructor won't be called because of reference - that's why PHP leeks memory. Am I right? regards, Wojtek

(Marcus Börger)

23 years ago
At 19:32 22.05.2003, Wojtek Meler wrote:
>When you run: ><? >$a=array(); >$b[]=&$a; >$a[]=&$b; >?> > >You will get warnings about memory leaks. I know that it is ugly code etc. >but shouldn't it be solved by ZE? It should free such things properly. >I know that in this simple case whole memory is freed, but if we add >resource to $a table, resource desctructor won't be called because >of reference - that's why PHP leeks memory. Am I right?
Putting out the warning is better. Eventually a damn note that the user shoot his self in the knee. But that would slow down performance. AND a side note: even java does not handle that. regards marcus

Wojtek Meler

23 years ago
Marcus Börger wrote:
> Putting out the warning is better. > Eventually a damn note that the user shoot his self in the knee. > But that would slow down performance.
I know, but memory leaks are pain in back. There is also another solution - it is possible to call destructor just before cleaning memory without taking care about reference numbers. They just shouldn't be unregistered from resources table before there are still references in userland.
> AND a side note: even java does not handle that.
hmm... http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html it seems they do ... regards Wojtek

Wei He

23 years ago
On Thu, 22 May 2003, Wojtek Meler wrote:
> When you run: > <? > $a=array(); > $b[]=&$a; > $a[]=&$b; > ?> >
I'm also interested in it but I didn't see the warning on my platform running your example. Wei He

Wojtek Meler

23 years ago
Wei He wrote:
>On Thu, 22 May 2003, Wojtek Meler wrote: > > > >>When you run: >><? >>$a=array(); >>$b[]=&$a; >>$a[]=&$b; >>?> >> >> >> > >I'm also interested in it but I didn't see the warning on my platform >running your example. > >Wei He > > > >
maybe try 'config.nice --enable-debug' ?