01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.runtime;
05:
06: import com.tc.logging.TCLogger;
07: import com.tc.logging.TCLogging;
08:
09: import java.lang.management.ManagementFactory;
10: import java.lang.management.MemoryMXBean;
11:
12: class TCMemoryManagerJdk15Basic implements JVMMemoryManager {
13:
14: private static final TCLogger logger = TCLogging
15: .getLogger(TCMemoryManagerJdk15Basic.class);
16:
17: private final MemoryMXBean memoryBean;
18:
19: public TCMemoryManagerJdk15Basic() {
20: memoryBean = ManagementFactory.getMemoryMXBean();
21: java.lang.management.MemoryUsage heapUsage = memoryBean
22: .getHeapMemoryUsage();
23: if (heapUsage.getMax() <= 0) {
24: logger
25: .warn("Please specify Max memory using -Xmx flag for Memory manager to work properly");
26: }
27: }
28:
29: public boolean isMemoryPoolMonitoringSupported() {
30: return false;
31: }
32:
33: public MemoryUsage getMemoryUsage() {
34: java.lang.management.MemoryUsage heapUsage = memoryBean
35: .getHeapMemoryUsage();
36: // TODO:: Supporting collectionCount in future. Get a cumulative collectionCount from every collector
37: return new Jdk15MemoryUsage(heapUsage, "VM 1.5 Heap Usage");
38: }
39:
40: public MemoryUsage getOldGenUsage() {
41: throw new UnsupportedOperationException();
42: }
43: }
|