Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1941 (closed defect: fixed)

Opened 14 years ago

Last modified 14 years ago

Multiple bugs in GC minimize()

Reported by: llucax Assigned to: community
Priority: major Milestone: 1.0
Component: Runtime Version: 0.99.9 Kai
Keywords: Cc: llucax

Description

I found a couple of bugs in the minimize() function of the GC.

Here is some kind of patch that fixes the bugs (and add a little enhancement), with inline comments (this is found in tango/core/rt/gc/basic/gcx.d):

    /**
     * Minimizes physical memory usage by returning free pools to the OS.
     */
    void minimize()
    {   
        size_t n;
        size_t pn;
        Pool*  pool;
        size_t ncommitted;

        for (n = 0; n < npools; n++)
        {   
            pool = pooltable[n];
            ncommitted = pool.ncommitted;
            for (pn = 0; pn < ncommitted; pn++)
            {   
                if (cast(Bins)pool.pagetable[pn] != B_FREE)
                    break;
            }
            if (pn < ncommitted)
            {   
-               n++; // n++ is done by the for loop, this skips a pool
                continue;
            }
            pool.Dtor();
            cstdlib.free(pool);
            cstring.memmove(pooltable + n,
                            pooltable + n + 1,
                            (--npools - n) * (Pool*).sizeof);
+           n--; // without this, we are skipping the first moved pool
-           minAddr = pooltable[0].baseAddr;
-           maxAddr = pooltable[npools - 1].topAddr;
        }
+       minAddr = pooltable[0].baseAddr;         // there is no point on doing
+       maxAddr = pooltable[npools - 1].topAddr; // this for each moved pool
    }

Change History

06/27/10 23:07:13 changed by mwarning

Thanks again. :)

06/27/10 23:19:06 changed by mwarning

  • status changed from new to closed.
  • resolution set to fixed.

06/27/10 23:22:08 changed by mwarning

fixed in [5491]