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