Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cyclic references will leak? #5

Open
ClosetGeek-Git opened this issue Nov 4, 2018 · 1 comment
Open

cyclic references will leak? #5

ClosetGeek-Git opened this issue Nov 4, 2018 · 1 comment

Comments

@ClosetGeek-Git
Copy link

ClosetGeek-Git commented Nov 4, 2018

The README states "cyclic references will leak" in the data structure section. Can you detail this further?

@tpunt
Copy link
Owner

tpunt commented Nov 17, 2018

Yeah sure. Cyclic references occur when you nest an object (or an array reference) within itself. In normal PHP code, this looks something like the following:

$o = new StdClass();
$o->prop = $o;

So the prop property references the object itself, forming a cycle. PHP has a mark-and-sweep cycle detector to handle these cycles, but I haven't written this for pht (and I don't really plan to, in the interest of simplicity). So if you do something like the following in pht:

$queue = new Queue();
$queue->push($queue);

Then this will leak, since the extension handles garbage collection of these object across threads (so it avoids using PHP's garbage collection mechanism).

Due to the simplicity of the data structures, I don't see any strong reasons as to why cyclic referencing would be needed anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants