Realtime monitoring of GC

wobbles via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 26 15:55:54 PDT 2016


In the Java world, the JVM offers hooks to allow tools to monitor 
in real time what is happening under the hood of your application.

I think this sort of tooling would be very useful in D. 
Especially in my current Game Dev project (it'd be really nice to 
see in real time where you're allocating).

I've had a quick look, and the current -profile=gc code should be 
pretty adaptable.
We'd just have to make available a public 'getter' of the current 
accumulated stats in profilegc.d [1].

I'm no compiler programmer, so:
1) I'm here looking for advice on whether this is even the 
correct way to go about it?

2) What would be the best way to make it available to the end 
user?
      Through a function call in core.runtime?
      Or maybe a compiler switch that prints to a file every X 
seconds?

My current (hacky) attempt is here [2]:

It copy/paste from other code, and would need cleaning up. But, 
it's a proof of concept at least.

I provide access to user code through a function in core.runtime;
It's in use in sample code here: [3]

Thanks!
Colin

[1] 
https://github.com/dlang/druntime/blob/master/src/rt/profilegc.d
[2] 
https://github.com/grogancolin/druntime/tree/realtimeGCMonitoring
[3] 
https://gist.github.com/grogancolin/a96a33f3b6d36c820e63982ced116eca


More information about the Digitalmars-d mailing list