Project

General

Profile

Revision d18bb640

IDd18bb6400f8367d479ad308c2fc7d457c64cb4a8
Parent 91af72e5
Child 33ca6770

Added by Katja Luther almost 6 years ago

View differences:

.gitattributes
1564 1564
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/CacheStrategyGeneratorTest.java -text
1565 1565
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/CdmDeleteListenerTest.java -text
1566 1566
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/replace/ReferringObjectMetadataFactoryTest.java -text
1567
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/profiler/ProfilerController.java -text
1567 1568
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java -text
1568 1569
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/TestCdmApplicationUtils.java -text
1569 1570
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/TestPersistence.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/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.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
            }
32
        }
33
    }
34

  
35
    public static void memorySnapshot() {
36
        init();
37
        try {
38
            controller.forceGC();
39
            logger.info("snapshot " + memSnapshotCnt++ + " to file: " + controller.captureMemorySnapshot());
40
        } catch (Exception e) {
41
            logger.info("taking memory snapshot " + memSnapshotCnt + " failed");
42
        }
43
    }
44

  
45
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)