1
2
3
4
5
6
7
8
9
10 package eu.etaxonomy.cdm.io.profiler;
11
12 import org.apache.log4j.Logger;
13
14 import com.yourkit.api.Controller;
15
16 public class ProfilerController {
17
18
19 private static final Logger logger = Logger.getLogger(ProfilerController.class);
20
21 private static Controller controller;
22 private static int memSnapshotCnt = 0;
23
24 private static void init(){
25 if(controller == null){
26 try {
27 controller = new Controller();
28 memSnapshotCnt = 0;
29 } catch (Exception e) {
30 logger.error(e);
31 }
32 }
33 }
34
35 public static void memorySnapshot() {
36 init();
37 try {
38 logger.info("taking memory snapshot " + memSnapshotCnt++);
39 controller.captureMemorySnapshot();
40 } catch (Exception e) {
41 logger.error("taking memory snapshot " + memSnapshotCnt++, e);
42 }
43 }
44
45 }