Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.4.0)

E90870-01

coherence/lang/ObjectCountHeapAnalyzer.hpp

00001 /*
00002 * ObjectCountHeapAnalyzer.hpp
00003 *
00004 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_OBJECT_COUNT_HEAP_ANALYZER_HPP
00017 #define COH_OBJECT_COUNT_HEAP_ANALYZER_HPP
00018 
00019 #include "coherence/lang/compatibility.hpp"
00020 
00021 #include "coherence/lang/HeapAnalyzer.hpp"
00022 #include "coherence/native/NativeAtomic64.hpp"
00023 
00024 
00025 
00026 COH_OPEN_NAMESPACE2(coherence,lang)
00027 
00028 using coherence::native::NativeAtomic64;
00029 
00030 /**
00031 * ObjectCountHeapAnalyzer provides simple heap analysis based solely on the
00032 * count of the number of live objects in the system.
00033 *
00034 * This heap analyzer has low CPU and memory costs. It is well suited for
00035 * performance sensitive production environments.
00036 *
00037 * @see ClassBasedHeapAnalyzer for more detailed heap analysis
00038 *
00039 * @author mf  2008.04.27
00040 */
00041 class COH_EXPORT ObjectCountHeapAnalyzer
00042     : public class_spec<ObjectCountHeapAnalyzer,
00043         extends<Object>,
00044         implements<HeapAnalyzer> >
00045     {
00046     friend class factory<ObjectCountHeapAnalyzer>;
00047 
00048     // ----- constructor ----------------------------------------------------
00049 
00050     protected:
00051         /**
00052         * Create a new ObjectCountHeapAnalyzer.
00053         *
00054         * @return the analyzer
00055         */
00056         ObjectCountHeapAnalyzer();
00057 
00058 
00059     // ----- nested class: Snapshot -----------------------------------------
00060 
00061     public:
00062         /**
00063         * Snapshot containing the object count.
00064         */
00065         class COH_EXPORT Snapshot
00066             : public class_spec<Snapshot,
00067                 extends<Object>,
00068                 implements<HeapAnalyzer::Snapshot> >
00069             {
00070             friend class factory<Snapshot>;
00071 
00072             // ----- constructors ---------------------------------------
00073 
00074             protected:
00075                 /**
00076                 * Create a new Snapshot.
00077                 *
00078                 * @param cObjects  the object count
00079                 *
00080                 * @return the new snapshot
00081                 */
00082                 Snapshot(int64_t cObjects);
00083 
00084             // ----- Snapshot interface ---------------------------------
00085 
00086             public:
00087                 /**
00088                 * {@inheritDoc}
00089                 */
00090                 virtual int64_t getObjectCount() const;
00091 
00092                 /**
00093                 * {@inheritDoc}
00094                 */
00095                 virtual HeapAnalyzer::Snapshot::View delta(
00096                         HeapAnalyzer::Snapshot::View vThat) const;
00097 
00098             // ----- Object interface: ----------------------------------
00099 
00100             public:
00101                 /**
00102                 * {@inheritDoc}
00103                 */
00104                 virtual TypedHandle<const String> toString() const;
00105 
00106             // ----- data members ---------------------------------------
00107 
00108             protected:
00109                 /**
00110                 * The object count.
00111                 */
00112                 int64_t m_cObjects;
00113             };
00114 
00115 
00116     // ----- HeapAnalyzer interface -----------------------------------------
00117 
00118     public:
00119         /**
00120         * {@inheritDoc}
00121         */
00122         virtual HeapAnalyzer::Snapshot::View capture() const;
00123 
00124         /**
00125         * {@inheritDoc}
00126         */
00127         virtual HeapAnalyzer::Snapshot::View delta(
00128                 HeapAnalyzer::Snapshot::View vSnap) const;
00129 
00130         /**
00131         * {@inheritDoc}
00132         */
00133         virtual int64_t getObjectCount() const;
00134 
00135         /**
00136         * {@inheritDoc}
00137         */
00138         virtual int64_t getImmortalCount() const;
00139 
00140     protected:
00141         /**
00142         * {@inheritDoc}
00143         */
00144         virtual void registerObject(const Object& o);
00145 
00146         /**
00147         * {@inheritDoc}
00148         */
00149         virtual void unregisterObject(const Object& o);
00150 
00151         /**
00152         * {@inheritDoc}
00153         */
00154         virtual void registerImmortal(const Object& o);
00155 
00156 
00157     // ----- Object interface -----------------------------------------------
00158 
00159     public:
00160         /**
00161         * {@inheritDoc}
00162         */
00163         virtual TypedHandle<const String> toString() const;
00164 
00165 
00166     // ----- data members ---------------------------------------------------
00167 
00168     protected:
00169         /**
00170         * The size of the array of counters.
00171         */
00172         static const size_t s_cCount = 257;
00173 
00174         /**
00175         * Array of object counts.
00176         */
00177         NativeAtomic64 m_acObjects[s_cCount];
00178 
00179         /**
00180          * The immortal object count.
00181          */
00182         NativeAtomic64 m_cImmortals;
00183     };
00184 
00185 COH_CLOSE_NAMESPACE2
00186 
00187 #endif // COH_OBJECT_COUNT_HEAP_ANALYZER_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.