1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.io.profiler;
|
11
|
|
12
|
import org.apache.log4j.Logger;
|
13
|
|
14
|
import com.yourkit.api.Controller;
|
15
|
//TODO move to common
|
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
|
}
|