aboutsummaryrefslogtreecommitdiff
path: root/src/memusage.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-07-17 13:46:18 -0400
committerPieter Wuille <pieter.wuille@gmail.com>2015-07-20 11:17:53 -0400
commit9e38d0f7451092f6a16853a2b0a37b68a5b3c3fb (patch)
tree469af8922b6454945e160b99e118d35873470180 /src/memusage.h
parent89289d875da108c42ca013f33597eda46cb6eb53 (diff)
Separate core memory usage computation in core_memusage.h
Diffstat (limited to 'src/memusage.h')
-rw-r--r--src/memusage.h66
1 files changed, 1 insertions, 65 deletions
diff --git a/src/memusage.h b/src/memusage.h
index 7a831e6d33..be3964df1b 100644
--- a/src/memusage.h
+++ b/src/memusage.h
@@ -34,28 +34,14 @@ static inline size_t DynamicUsage(const float& v) { return 0; }
static inline size_t DynamicUsage(const double& v) { return 0; }
template<typename X> static inline size_t DynamicUsage(X * const &v) { return 0; }
template<typename X> static inline size_t DynamicUsage(const X * const &v) { return 0; }
-template<typename X, typename Y> static inline size_t DynamicUsage(std::pair<X, Y> &p) { return 0; }
/** Compute the memory used for dynamically allocated but owned data structures.
* For generic data types, this is *not* recursive. DynamicUsage(vector<vector<int> >)
* will compute the memory used for the vector<int>'s, but not for the ints inside.
* This is for efficiency reasons, as these functions are intended to be fast. If
* application data structures require more accurate inner accounting, they should
- * use RecursiveDynamicUsage, iterate themselves, or use more efficient caching +
- * updating on modification.
+ * iterate themselves, or use more efficient caching + updating on modification.
*/
-template<typename X> static size_t DynamicUsage(const std::vector<X>& v);
-template<typename X> static size_t DynamicUsage(const std::set<X>& s);
-template<typename X, typename Y> static size_t DynamicUsage(const std::map<X, Y>& m);
-template<typename X, typename Y> static size_t DynamicUsage(const boost::unordered_set<X, Y>& s);
-template<typename X, typename Y, typename Z> static size_t DynamicUsage(const boost::unordered_map<X, Y, Z>& s);
-template<typename X> static size_t DynamicUsage(const X& x);
-
-template<typename X> static size_t RecursiveDynamicUsage(const std::vector<X>& v);
-template<typename X> static size_t RecursiveDynamicUsage(const std::set<X>& v);
-template<typename X, typename Y> static size_t RecursiveDynamicUsage(const std::map<X, Y>& v);
-template<typename X, typename Y> static size_t RecursiveDynamicUsage(const std::pair<X, Y>& v);
-template<typename X> static size_t RecursiveDynamicUsage(const X& v);
static inline size_t MallocUsage(size_t alloc)
{
@@ -89,53 +75,17 @@ static inline size_t DynamicUsage(const std::vector<X>& v)
}
template<typename X>
-static inline size_t RecursiveDynamicUsage(const std::vector<X>& v)
-{
- size_t usage = DynamicUsage(v);
- BOOST_FOREACH(const X& x, v) {
- usage += RecursiveDynamicUsage(x);
- }
- return usage;
-}
-
-template<typename X>
static inline size_t DynamicUsage(const std::set<X>& s)
{
return MallocUsage(sizeof(stl_tree_node<X>)) * s.size();
}
-template<typename X>
-static inline size_t RecursiveDynamicUsage(const std::set<X>& v)
-{
- size_t usage = DynamicUsage(v);
- BOOST_FOREACH(const X& x, v) {
- usage += RecursiveDynamicUsage(x);
- }
- return usage;
-}
-
template<typename X, typename Y>
static inline size_t DynamicUsage(const std::map<X, Y>& m)
{
return MallocUsage(sizeof(stl_tree_node<std::pair<const X, Y> >)) * m.size();
}
-template<typename X, typename Y>
-static inline size_t RecursiveDynamicUsage(const std::map<X, Y>& v)
-{
- size_t usage = DynamicUsage(v);
- for (typename std::map<X, Y>::const_iterator it = v.begin(); it != v.end(); it++) {
- usage += RecursiveDynamicUsage(*it);
- }
- return usage;
-}
-
-template<typename X, typename Y>
-static inline size_t RecursiveDynamicUsage(const std::pair<X, Y>& v)
-{
- return RecursiveDynamicUsage(v.first) + RecursiveDynamicUsage(v.second);
-}
-
// Boost data structures
template<typename X>
@@ -157,20 +107,6 @@ static inline size_t DynamicUsage(const boost::unordered_map<X, Y, Z>& m)
return MallocUsage(sizeof(boost_unordered_node<std::pair<const X, Y> >)) * m.size() + MallocUsage(sizeof(void*) * m.bucket_count());
}
-// Dispatch to class method as fallback
-
-template<typename X>
-static inline size_t DynamicUsage(const X& x)
-{
- return x.DynamicMemoryUsage();
-}
-
-template<typename X>
-static inline size_t RecursiveDynamicUsage(const X& x)
-{
- return DynamicUsage(x);
-}
-
}
#endif