Skip Menu |

This queue is for tickets about the Promises CPAN distribution.

Report information
The Basics
Id: 84720
Status: open
Priority: 0/
Queue: Promises

People
Owner: Nobody in particular
Requestors: WULEE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.03
Fixed in: (no value)



Subject: Does Promises::Promise contain a cycling reference?
Hello, This is not *exactly* a bug report, as I am still trying to unpick the logic in this module. (Just for fun, although it isn't particularly easy to follow.) However it looks to me that Promises::Deferred->new constructs a Promises::Promise object, which refers to itself, and then stores that as an attribute in itself. I can't find anything which breaks that cyclic reference. Am I missing something? As this was translated from Javascript which typically has a fancier garbage collector than Perl's refcounting, my guess is that this actually works fine in Javascript, but nevertheless would leak in Perl. And if this is true there may be other more subtle memory leaks involving closures, although I've not spotted any so far. Promises::Promise seems to be just a proxy for a Promises::Deferred, I'm guessing this is to isolate the users of the promise from the creator and prevent naughty things happening. P::P doesn't store any state of its own. Therefore I'm wondering if P::D actually needs to store a reference to a promise, or if the ->promise method could just construct one on demand.
Subject: Re: [rt.cpan.org #84720] Does Promises::Promise contain a cycling reference?
Date: Thu, 18 Apr 2013 12:36:44 -0400
To: "bug-Promises [...] rt.cpan.org" <bug-Promises [...] rt.cpan.org>
From: Stevan Little <stevan.little [...] iinteractive.com>
This is entirely possible, I have not tested this to check. You could try using Test::Memory::Cycle to see for sure. Stevan On Apr 18, 2013, at 12:10 PM, "Nick Stokoe via RT" <bug-Promises@rt.cpan.org> wrote: Show quoted text
> Thu Apr 18 12:10:19 2013: Request 84720 was acted upon. > Transaction: Ticket created by WULEE > Queue: Promises > Subject: Does Promises::Promise contain a cycling reference? > Broken in: 0.03 > Severity: (no value) > Owner: Nobody > Requestors: WULEE@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84720 > > > > Hello, > > This is not *exactly* a bug report, as I am still trying to unpick the logic in this module. (Just for fun, although it isn't particularly easy to follow.) > > However it looks to me that Promises::Deferred->new constructs a Promises::Promise object, which refers to itself, and then stores that as an attribute in itself. > > I can't find anything which breaks that cyclic reference. Am I missing something? > > As this was translated from Javascript which typically has a fancier garbage collector than Perl's refcounting, my guess is that this actually works fine in Javascript, but nevertheless would leak in Perl. And if this is true there may be other more subtle memory leaks involving closures, although I've not spotted any so far. > > Promises::Promise seems to be just a proxy for a Promises::Deferred, I'm guessing this is to isolate the users of the promise from the creator and prevent naughty things happening. P::P doesn't store any state of its own. Therefore I'm wondering if P::D actually needs to store a reference to a promise, or if the ->promise method could just construct one on demand. > > >
From: karjala [...] karjala.org
I believe Promises leaks memory. Run this script for instance, and check your RAM usage with top: #!/usr/bin/perl use v5.18; use warnings; use EV; use AnyEvent; use Promises qw/ deferred /; for (my $i = 0; $i <= 1_000_000; $i++) { my $d = deferred; $d->then(sub {}); } EV::run;
Subject: Re: [rt.cpan.org #84720] Does Promises::Promise contain a cycling reference?
Date: Tue, 24 Jun 2014 09:44:25 -0400
To: bug-Promises [...] rt.cpan.org
From: Stevan Little <stevan.little [...] gmail.com>
Alexander, There is actually a pull-request to fix this ( https://github.com/stevan/promises-perl/pull/32) but I am currently too busy to be able to get to it and make the few tweaks that need to be made to it (see clinton gormley's comments). I can try and get to it in the next couple weeks or so, or if you feel so inclined to make the tweaks yourself I would happily accept them and get a release out the door. - Stevan On Tue, Jun 24, 2014 at 6:40 AM, Alexander Karelas via RT < bug-Promises@rt.cpan.org> wrote: Show quoted text
> Queue: Promises > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84720 > > > I believe Promises leaks memory. Run this script for instance, and check > your RAM usage with top: > > #!/usr/bin/perl > > use v5.18; > use warnings; > > use EV; > use AnyEvent; > use Promises qw/ deferred /; > > for (my $i = 0; $i <= 1_000_000; $i++) { > my $d = deferred; > $d->then(sub {}); > } > > EV::run; >