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


Leandro Lucarella <llu...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |llu...@gmail.com
            Version|0.157                       |D1


--- Comment #2 from Leandro Lucarella <llu...@gmail.com> 2010-08-15 17:56:13 
PDT ---
This is fixed in D2 and here is a patch based on druntime for Phobos 1:

--- gcx.orig.d  2010-08-15 21:42:21.837000089 -0300
+++ gcx.new.d   2010-08-15 21:52:24.319000075 -0300
@@ -1038,7 +1038,10 @@ class GC

     void minimize()     // minimize physical memory usage
     {
-        // Not implemented, ignore
+        synchronized (gcLock)
+        {
+            gcx.minimize();
+        }
     }

     void setFinalizer(void *p, GC_FINALIZER pFn)
@@ -2252,6 +2255,39 @@ struct Gcx
     }


+    /**
+     * 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)
+                continue;
+            pool.Dtor();
+            cstdlib.free(pool);
+            memmove(pooltable + n,
+                    pooltable + n + 1,
+                    (--npools - n) * (Pool*).sizeof);
+            n--;
+        }
+        minAddr = pooltable[0].baseAddr;
+        maxAddr = pooltable[npools - 1].topAddr;
+    }
+
+
     /**
      * Run finalizer on p when it is free'd.
      */


It might be probably a good idea to call minimize() after fullcollect() too.

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

Reply via email to