Revision ca25937d
Added by Katja Luther over 9 years ago
.gitattributes | ||
---|---|---|
32 | 32 |
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/monitor/ProgressMonitorWrapper.java -text |
33 | 33 |
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/monitor/RestServiceProgressMonitor.java -text |
34 | 34 |
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/monitor/SubProgressMonitor.java -text |
35 |
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/profiler/ProfilerController.java -text |
|
36 | 35 |
cdmlib-commons/src/main/resources/MUST-EXIST.txt -text |
37 | 36 |
cdmlib-commons/src/main/resources/log4j.properties -text |
38 | 37 |
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/CdmUtilsTest.java -text |
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/profiler/ProfilerController.java | ||
---|---|---|
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.common.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.info("The initialization of ProfilerController fails"); |
|
31 |
System.err.println("The initialization of ProfilerController fails " + e.getMessage()); |
|
32 |
} |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
public static void memorySnapshot() { |
|
37 |
init(); |
|
38 |
try { |
|
39 |
controller.forceGC(); |
|
40 |
logger.info("snapshot " + memSnapshotCnt++ + " to file: " + controller.captureMemorySnapshot()); |
|
41 |
System.out.println("snapshot " + memSnapshotCnt++ + " to file: " + controller.captureMemorySnapshot()); |
|
42 |
} catch (Exception e) { |
|
43 |
logger.info("taking memory snapshot " + memSnapshotCnt + " failed"); |
|
44 |
System.err.println("taking memory snapshot " + memSnapshotCnt + " failed " + e.getMessage()); |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
} |
Also available in: Unified diff