Skip to content

Commit 17a97ff

Browse files
committed
show GC stats in log
1 parent 83568e9 commit 17a97ff

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

vdc/dmdserver/dmdserver.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,8 @@ private:
10891089
auto time = profileStats.totalCollectionTime - mProfileStats.totalCollectionTime;
10901090
if(dbgfh)
10911091
dbglog("GC: " ~ to!string(count) ~ " collections took " ~ to!string(time.total!"msecs") ~ " ms, " ~
1092-
"now at " ~ to!string(stats.usedSize >> 20) ~ " MB");
1092+
"now using " ~ to!string(stats.usedSize >> 20) ~ " MB, " ~
1093+
to!string(stats.freeSize >> 20) ~ " MB free");
10931094

10941095
mProfileStats = profileStats;
10951096
}

visuald/vdserverclient.d

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ private void dbglog(string s)
9393
}
9494
writeToBuildOutputPane(cast(string)(strtm[0..len] ~ firstLine(s) ~ "\n"), false);
9595
}
96+
97+
void checkGCStats()
98+
{
99+
import core.memory;
100+
static GC.ProfileStats mProfileStats;
101+
auto profileStats = GC.profileStats();
102+
if (profileStats.numCollections == mProfileStats.numCollections)
103+
return;
104+
105+
auto stats = GC.stats();
106+
107+
auto count = profileStats.numCollections - mProfileStats.numCollections;
108+
auto time = profileStats.totalCollectionTime - mProfileStats.totalCollectionTime;
109+
dbglog("GC: " ~ to!string(count) ~ " collections took " ~ to!string(time.total!"msecs") ~ " ms, " ~
110+
"now using " ~ to!string(stats.usedSize >> 20) ~ " MB, " ~
111+
to!string(stats.freeSize >> 20) ~ " MB free");
112+
113+
mProfileStats = profileStats;
114+
}
115+
96116
}
97117

98118
///////////////////////////////////////////////////////////////////////
@@ -1122,6 +1142,8 @@ class VDServerClient
11221142
}
11231143
))
11241144
{
1145+
version(DebugCmd) if (dbglog_enabled)
1146+
checkGCStats();
11251147
}
11261148
}
11271149
catch(Throwable e)

0 commit comments

Comments
 (0)