www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4369] New: Multiple bugs in GC minimize()

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4369

           Summary: Multiple bugs in GC minimize()
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean invisibleduck.org
        ReportedBy: llucax gmail.com



PDT ---
This is basically the same bug I reported to Tango:
http://www.dsource.org/projects/tango/ticket/1941

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 gc/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
    }

---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 22 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4369


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dsimcha yahoo.com
         Resolution|                            |FIXED



Fixed 2.048.

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