[Issue 16564] New: KRRegion.empty sometimes returns Ternary.no

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Sep 29 02:20:58 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16564

          Issue ID: 16564
           Summary: KRRegion.empty sometimes returns Ternary.no
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: temtaime at gmail.com

I just tried it as video memory allocator for my engine and empty sometimes
don't work: try to allocate and then deallocate in a random order.

For example

void main()
{
    ubyte[256 * 1024] buf;
    auto a = KRRegion!()(buf);

    while(true)
    {
        void[][] bufs;

        foreach(_; 0..10_000)
        {
            bufs ~= a.allocate(uniform(1, buf.length));
        }

        foreach(b; bufs.randomCover)
        {
            a.deallocate(b);
        }

        if(a.empty == Ternary.no) break;
    }

    writeln(`all the elements are freed but allocator is not empty !`);
}

--


More information about the Digitalmars-d-bugs mailing list