00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_CLASS_BASED_HEAP_ANALYZER_HPP
00017 #define COH_CLASS_BASED_HEAP_ANALYZER_HPP
00018
00019 #include "coherence/lang/compatibility.hpp"
00020
00021 #include "coherence/lang/AbstractHeapAnalyzer.hpp"
00022 #include "coherence/lang/Comparable.hpp"
00023 #include "coherence/lang/FinalView.hpp"
00024
00025 #include "coherence/native/NativeAtomic64.hpp"
00026
00027
00028
00029 COH_OPEN_NAMESPACE2(coherence,util)
00030 class Map;
00031 COH_CLOSE_NAMESPACE2
00032
00033 COH_OPEN_NAMESPACE2(coherence,lang)
00034
00035 using coherence::util::Map;
00036 using coherence::native::NativeAtomic64;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 class COH_EXPORT ClassBasedHeapAnalyzer
00052 : public class_spec<ClassBasedHeapAnalyzer,
00053 extends<AbstractHeapAnalyzer> >
00054 {
00055 friend class factory<ClassBasedHeapAnalyzer>;
00056
00057
00058
00059 protected:
00060
00061
00062
00063
00064
00065 ClassBasedHeapAnalyzer(bool fShowAllocations = false);
00066
00067
00068
00069
00070 public:
00071
00072
00073
00074 class COH_EXPORT ClassStats
00075 : public class_spec<ClassStats,
00076 extends<Object>,
00077 implements<Comparable> >
00078 {
00079 friend class factory<ClassStats>;
00080
00081 protected:
00082
00083
00084
00085
00086
00087
00088
00089
00090 ClassStats(int64_t cObjs, int64_t cBytes, int64_t cAlloc);
00091
00092
00093
00094 public:
00095
00096
00097
00098 virtual int64_t getObjectCount() const;
00099
00100
00101
00102
00103 virtual int64_t getByteCount() const;
00104
00105
00106
00107
00108 virtual int64_t getAllocationCount() const;
00109
00110
00111
00112 public:
00113
00114
00115
00116 int32_t compareTo(Object::View v) const;
00117
00118
00119
00120 public:
00121
00122
00123
00124 virtual TypedHandle<const String> toString() const;
00125
00126
00127
00128 protected:
00129
00130
00131
00132 int64_t m_cInstanceCount;
00133
00134
00135
00136
00137 int64_t m_cByteCount;
00138
00139
00140
00141
00142 int64_t m_cAllocationCount;
00143 };
00144
00145
00146
00147 public:
00148
00149
00150
00151 class COH_EXPORT Snapshot
00152 : public class_spec<Snapshot,
00153 extends<Object>,
00154 implements<HeapAnalyzer::Snapshot> >
00155 {
00156 friend class factory<Snapshot>;
00157
00158
00159
00160 protected:
00161
00162
00163
00164 Snapshot(TypedHandle<const Map> vMap, bool fShowAllocations);
00165
00166
00167
00168 public:
00169
00170
00171
00172
00173
00174
00175
00176 virtual TypedHandle<const Map> getStatsMap() const;
00177
00178
00179
00180
00181 virtual int64_t getObjectCount() const;
00182
00183
00184
00185
00186 virtual HeapAnalyzer::Snapshot::View delta(
00187 HeapAnalyzer::Snapshot::View vThat) const;
00188
00189
00190
00191 public:
00192
00193
00194
00195 virtual TypedHandle<const String> toString() const;
00196
00197
00198
00199 protected:
00200
00201
00202
00203 FinalView<Object> f_vMapStats;
00204
00205
00206
00207
00208 bool m_fShowAllocations;
00209 };
00210
00211
00212
00213
00214 protected:
00215
00216
00217
00218 virtual void safeRegisterObject(const Object& o);
00219
00220
00221
00222
00223 virtual void safeUnregisterObject(const Object& o);
00224
00225
00226
00227
00228 public:
00229
00230
00231
00232 virtual HeapAnalyzer::Snapshot::View capture() const;
00233
00234
00235
00236
00237 virtual HeapAnalyzer::Snapshot::View delta(
00238 HeapAnalyzer::Snapshot::View vSnap) const;
00239
00240
00241
00242
00243 virtual int64_t getObjectCount() const;
00244
00245
00246
00247
00248 virtual int64_t getImmortalCount() const;
00249
00250 protected:
00251
00252
00253
00254 virtual void registerObject(const Object& o);
00255
00256
00257
00258
00259 virtual void unregisterObject(const Object& o);
00260
00261
00262
00263
00264 virtual void registerImmortal(const Object& o);
00265
00266
00267
00268
00269 protected:
00270
00271
00272
00273 bool m_fShowAllocations;
00274
00275
00276
00277
00278 NativeAtomic64 m_cImmortals;
00279
00280
00281
00282
00283 friend class Snapshot;
00284 };
00285
00286 COH_CLOSE_NAMESPACE2
00287
00288 #endif // COH_CLASS_BASED_HEAP_ANALYZER_HPP