+/**\r
+* Copyright (C) 2009 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/ \r
+\r
+package eu.etaxonomy.cdm.profiler;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import com.yourkit.api.Controller;\r
+//TODO move to common\r
+public class ProfilerController {\r
+ \r
+\r
+ private static final Logger logger = Logger.getLogger(ProfilerController.class);\r
+ \r
+ private static Controller controller;\r
+ private static int memSnapshotCnt = 0;\r
+ \r
+ private static void init(){\r
+ if(controller == null){\r
+ try {\r
+ controller = new Controller();\r
+ memSnapshotCnt = 0;\r
+ } catch (Exception e) {\r
+ logger.info("The initialization of ProfilerCOntroller fails");\r
+ }\r
+ }\r
+ }\r
+ \r
+ public static void memorySnapshot() {\r
+ init();\r
+ try {\r
+ logger.info("taking memory snapshot " + memSnapshotCnt++);\r
+ controller.captureMemorySnapshot();\r
+ } catch (Exception e) {\r
+ logger.info("taking memory snapshot " + memSnapshotCnt++ + " fails");\r
+ }\r
+ }\r
+\r
+}\r