[Issue 3523] New: Fiber is not garbage collected properly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 18 19:50:34 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3523

           Summary: Fiber is not garbage collected properly
           Product: D
           Version: 2.032
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean at invisibleduck.org
        ReportedBy: baryluk at smp.if.uj.edu.pl


--- Comment #0 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2009-11-18 19:50:33 PST ---
Program below leaks memory.

import core.thread;
import std.stdio;

lass DerivedFiber : Fiber {
  this() { super( &run );  }
 private void run() { Fiber.yield(); }
}

import core.memory : GC;

void main() {
    foreach (i ; 1 .. 1000000) {
        Fiber derived = new DerivedFiber();
        derived.call();
        GC.collect(); // doesn't work
    }
}

Manual destruction of fiber works:
              delete derived;
        }
and then it doesn't leek.

chaning Fiber to "scope" also works (just like delete befor "}"

I know it have something to do with similarity of Fiber to thread, that Fiber
have own pool of root variables and own stack. But if Fiber is not running, and
it is not accesible by any reference from any Thread, then it is imposible to
resume its operation by call(), so also it's root variables and stack is not
avaible, so it can (and should?) be garbage collected.

I have code which creates few fibers, do milions call/yield operations, then
destroy fibers, and recreat new ones, for and essentially repeats. I was hoping
this would not leak memory. Unfortonetly it is.

I this is intended behaviour it should be documented somewhere.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list