Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

YourKit probe class that allows one to capture memory snapshots after certain phases has run in the Scala compiler.

View MemoryProbe.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
import com.yourkit.probes.*;
import com.yourkit.api.*;
 
@MethodPattern("scala.tools.nsc.Global$Run:advancePhase()")
public class MemoryProbe {
 
public static void onEnter(@This scala.tools.nsc.Global.Run run) {
scala.reflect.internal.Phase patmatPhase = run.phaseNamed("patmat");
scala.reflect.internal.Phase postErasurePhase = run.phaseNamed("posterasure");
scala.reflect.internal.Phase icodePhase = run.phaseNamed("icode");
if (run.runIsAt(patmatPhase)) {
handlePhase(patmatPhase);
} else if (run.runIsAt(postErasurePhase)) {
handlePhase(postErasurePhase);
} else if (run.runIsAt(icodePhase)) {
handlePhase(icodePhase);
}
}
 
private static void handlePhase(scala.reflect.internal.Phase phase) {
try {
String name = phase.name();
System.out.println("After phase " + name);
Controller controller = new Controller();
controller.advanceGeneration(name);
System.gc();
System.gc();
controller.captureMemorySnapshot();
} catch (Exception e) {
System.out.println("Exception during taking memory dump " + e);
}
}
 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.