]> git.llucax.com Git - software/dgc/cdgc.git/blobdiff - rt/gc/cdgc/stats.d
Change the min_free default to 5%
[software/dgc/cdgc.git] / rt / gc / cdgc / stats.d
index 036d748c5d9f03d8419aec9106eb2c85e982fdf0..b854812eab740a31cfe5cd1a498dd883a6b9aba2 100644 (file)
@@ -157,7 +157,7 @@ struct Stats
 private:
 
     /// The GC instance we are collecting stats from.
-    .gc.GC gc = null;
+    .gc.GC* gc = null;
 
     /// True if statistics should be collected.
     bool active = false;
@@ -188,13 +188,13 @@ private:
     /// Fill a MemoryInfo struct with the current state of the GC heap.
     void fill_memory_info(MemoryInfo* mem_info)
     {
-        mem_info.overhead += .gc.GC.classinfo.init.length + .gc.Gcx.sizeof
-                + .gc.pools.size_of + .gc.roots.size_of + .gc.ranges.size_of;
+        mem_info.overhead += .gc.GC.sizeof + gc.pools.elements_sizeof +
+                gc.roots.elements_sizeof + gc.ranges.elements_sizeof;
 
         // pools
-        for (size_t i = 0; i < .gc.pools.length; i++)
+        for (size_t i = 0; i < gc.pools.length; i++)
         {
-            auto pool = .gc.pools[i];
+            auto pool = gc.pools[i];
             mem_info.overhead += pool.npages * ubyte.sizeof;
             // the 5 bitmaps (mark, scan, free, final, noscan)
             mem_info.overhead += 5 * (GCBits.sizeof
@@ -228,8 +228,8 @@ private:
     cstdio.FILE* start_file(char* filename, char* header)
     {
         cstdio.FILE* file = cstdio.fopen(filename, "w");
-        assert (file !is null);
-        cstdio.fputs(header, file);
+        if (file !is null)
+            cstdio.fputs(header, file);
         return file;
     }
 
@@ -293,27 +293,29 @@ public:
      * the program start time (in seconds since the epoch) needs to be taken to
      * properly add timestamps to allocations and collections.
      */
-    static Stats opCall(.gc.GC gc)
+    static Stats opCall(.gc.GC* gc)
     {
         Stats this_;
         this_.gc = gc;
         if (options.malloc_stats_file[0] != '\0') {
-            this_.active = true;
             this_.mallocs_file = this_.start_file(
                     options.malloc_stats_file.ptr,
                     "Timestamp,Time,Pointer,Size,Collection triggered,"
                     "Finalize,No scan,No move,Pointer map,Type size,"
                     "Pointer map scan bitmask (first word, hexa),"
                     "Pointer map pointer bitmask (first word, hexa)\n");
+            if (this_.mallocs_file !is null)
+                this_.active = true;
         }
         // collection
         if (options.collect_stats_file[0] != '\0') {
-            this_.active = true;
             this_.collections_file = this_.start_file(
                     options.collect_stats_file.ptr,
                     "Timestamp,Malloc time,Collection time,Stop-the-world time,"
                     "Used before,Free before,Wasted before,Overhead before,"
                     "Used after,Free after,Wasted after,Overhead after\n");
+            if (this_.collections_file !is null)
+                this_.active = true;
         }
         this_.program_start = this_.now();
         return this_;