The delay pools classes were using custom new/delete methods to allocate and account for pool overheads in a single counter. There is no need for this with memory pools and it makes the debugging harder and code more complex overall.
This patch converts all the delay pools classes which were providing the new/delete operators to using MEMPROXY_CLASS instead. So each class in separately accounted for and we get a better view of allocation stats and behaviours from the mgr:mem report. Also, add construct/destruct debugs to DelayTagged and DelayTaggedBucket classes so the findalive.pl script can track the lifecycles of these classes. Both changes should make tracking down the reported leaks in the delay pools a lot easier. Though I have not at this time attempted to do so. Amos
=== modified file 'src/CommonPool.h' --- src/CommonPool.h 2017-01-01 00:12:22 +0000 +++ src/CommonPool.h 2017-01-13 06:04:40 +0000 @@ -9,32 +9,29 @@ /* DEBUG: section 77 Delay Pools */ #ifndef COMMONPOOL_H #define COMMONPOOL_H #if USE_DELAY_POOLS #include "CompositePoolNode.h" #include "SquidString.h" /* - \ingroup DelayPoolsAPI - * - \todo Next steps: make this a composite, and TypeLabel a composite method. + * TODO: make this a composite, and TypeLabel a composite method. * Then we have a legacy composite which returns class 1/2/3, and new * composites which return a descriptor of some sort. */ class CommonPool { + MEMPROXY_CLASS(CommonPool); public: - void *operator new(size_t); - void operator delete (void *); static CommonPool *Factory (unsigned char _class, CompositePoolNode::Pointer&); char const* theClassTypeLabel() const {return typeLabel.termedBuf();} protected: CommonPool(); String typeLabel; }; #endif /* USE_DELAY_POOLS */ #endif /* COMMONPOOL_H */ === modified file 'src/CompositePoolNode.h' --- src/CompositePoolNode.h 2017-01-01 00:12:22 +0000 +++ src/CompositePoolNode.h 2017-01-13 06:04:40 +0000 @@ -17,25 +17,24 @@ #include "DelayIdComposite.h" #include "DelayPools.h" #include "ip/Address.h" #include "SquidString.h" class StoreEntry; /// \ingroup DelayPoolsAPI class CompositePoolNode : public RefCountable, public Updateable { + MEMPROXY_CLASS(CompositePoolNode); public: typedef RefCount<CompositePoolNode> Pointer; - void *operator new(size_t); - void operator delete (void *); virtual ~CompositePoolNode() {} virtual void stats(StoreEntry * sentry) =0; virtual void dump(StoreEntry *entry) const =0; virtual void update(int incr) =0; virtual void parse() = 0; class CompositeSelectionDetails; virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &) = 0; void delayRead(DeferredRead const &); === modified file 'src/DelayPools.h' --- src/DelayPools.h 2017-01-01 00:12:22 +0000 +++ src/DelayPools.h 2017-01-13 06:04:40 +0000 @@ -36,21 +36,20 @@ public: static void Init(); static void Update(void *); static unsigned short pools(); static void pools(unsigned short pools); static void FreePools(); static unsigned char *DelayClasses(); static void registerForUpdates(Updateable *); static void deregisterForUpdates (Updateable *); - static long MemoryUsed; static DelayPool *delay_data; private: static void Stats(StoreEntry *); static void InitDelayData(); static time_t LastUpdate; static unsigned short pools_; static void FreeDelayData (); static std::vector<Updateable *> toUpdate; static void RegisterWithCacheManager(void); === modified file 'src/DelayTagged.cc' --- src/DelayTagged.cc 2017-01-01 00:12:22 +0000 +++ src/DelayTagged.cc 2017-01-13 06:04:40 +0000 @@ -9,44 +9,32 @@ /* DEBUG: section 77 Delay Pools */ #include "squid.h" #if USE_DELAY_POOLS #include "comm/Connection.h" #include "DelayTagged.h" #include "NullDelayId.h" #include "Store.h" -void * -DelayTagged::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (DelayTagged); - return ::operator new (size); -} - -void -DelayTagged::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (DelayTagged); - ::operator delete (address); -} - DelayTagged::DelayTagged() { - DelayPools::registerForUpdates (this); + debugs(77, 3, "construct, this=" << (void*)this); + DelayPools::registerForUpdates(this); } static Splay<DelayTaggedBucket::Pointer>::SPLAYFREE DelayTaggedFree; DelayTagged::~DelayTagged() { - DelayPools::deregisterForUpdates (this); + debugs(77, 3, "destruct, this=" << (void*)this); + DelayPools::deregisterForUpdates(this); buckets.destroy(DelayTaggedFree); } static Splay<DelayTaggedBucket::Pointer>::SPLAYCMP DelayTaggedCmp; int DelayTaggedCmp(DelayTaggedBucket::Pointer const &left, DelayTaggedBucket::Pointer const &right) { /* for rate limiting, case insensitive */ return left->tag.caseCmp(right->tag); @@ -131,82 +119,56 @@ DelayIdComposite::Pointer DelayTagged::id(CompositePoolNode::CompositeSelectionDetails &details) { if (!details.tag.size()) return new NullDelayId; return new Id(this, details.tag); } -void * -DelayTagged::Id::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (Id); - return ::operator new (size); -} - -void -DelayTagged::Id::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (Id); - ::operator delete (address); -} - -void * -DelayTaggedBucket::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (DelayTaggedBucket); - return ::operator new (size); -} - -void -DelayTaggedBucket::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (DelayTaggedBucket); - ::operator delete (address); -} - DelayTaggedBucket::DelayTaggedBucket(String &aTag) : tag (aTag) { - debugs(77, 3, "DelayTaggedBucket::DelayTaggedBucket"); + debugs(77, 3, "construct, this=" << (void*)this); } DelayTaggedBucket::~DelayTaggedBucket() { - debugs(77, 3, "DelayTaggedBucket::~DelayTaggedBucket"); + debugs(77, 3, "destruct, this=" << (void*)this); } void DelayTaggedBucket::stats(StoreEntry *entry) const { storeAppendPrintf(entry, " " SQUIDSTRINGPH ":", SQUIDSTRINGPRINT(tag)); theBucket.stats(entry); } DelayTagged::Id::Id(DelayTagged::Pointer aDelayTagged, String &aTag) : theTagged(aDelayTagged) { - theBucket = new DelayTaggedBucket(aTag); + debugs(77, 3, "construct, this=" << (void*)this); + DelayTaggedBucket::Pointer const *existing = theTagged->buckets.find(theBucket, DelayTaggedCmp); if (existing) { theBucket = *existing; return; } + theBucket = new DelayTaggedBucket(aTag); theBucket->theBucket.init(theTagged->spec); theTagged->buckets.insert (theBucket, DelayTaggedCmp); } DelayTagged::Id::~Id() { - debugs(77, 3, "DelayTagged::Id::~Id"); + debugs(77, 3, "destruct, this=" << (void*)this); } int DelayTagged::Id::bytesWanted (int min, int max) const { return theBucket->theBucket.bytesWanted(min,max); } void DelayTagged::Id::bytesIn(int qty) === modified file 'src/DelayTagged.h' --- src/DelayTagged.h 2017-01-01 00:12:22 +0000 +++ src/DelayTagged.h 2017-01-21 20:32:08 +0000 @@ -16,59 +16,60 @@ #include "auth/Gadgets.h" #include "CompositePoolNode.h" #include "DelayBucket.h" #include "DelayIdComposite.h" #include "DelaySpec.h" #include "splay.h" /// \ingroup DelayPoolsAPI class DelayTaggedBucket : public RefCountable { + MEMPROXY_CLASS(DelayTaggedBucket); public: typedef RefCount<DelayTaggedBucket> Pointer; - void *operator new(size_t); - void operator delete (void *); - void stats(StoreEntry *)const; DelayTaggedBucket(String &aTag); ~DelayTaggedBucket(); + + void stats(StoreEntry *) const; + +public: DelayBucket theBucket; String tag; }; /// \ingroup DelayPoolsAPI class DelayTagged : public CompositePoolNode { + MEMPROXY_CLASS(DelayTagged); public: typedef RefCount<DelayTagged> Pointer; - void *operator new(size_t); - void operator delete (void *); + DelayTagged(); virtual ~DelayTagged(); virtual void stats(StoreEntry * sentry); virtual void dump(StoreEntry *entry) const; virtual void update(int incr); virtual void parse(); virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &); private: /// \ingroup DelayPoolsInternal class Id:public DelayIdComposite { + MEMPROXY_CLASS(DelayTagged::Id); public: - void *operator new(size_t); - void operator delete (void *); Id (RefCount<DelayTagged>, String &); ~Id(); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); virtual void delayRead(DeferredRead const &); private: RefCount<DelayTagged> theTagged; DelayTaggedBucket::Pointer theBucket; }; === modified file 'src/DelayUser.cc' --- src/DelayUser.cc 2017-01-01 00:12:22 +0000 +++ src/DelayUser.cc 2017-01-13 06:04:40 +0000 @@ -11,34 +11,20 @@ #include "squid.h" #if USE_DELAY_POOLS && USE_AUTH #include "auth/User.h" #include "auth/UserRequest.h" #include "comm/Connection.h" #include "DelayUser.h" #include "NullDelayId.h" #include "Store.h" -void * -DelayUser::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (DelayUser); - return ::operator new (size); -} - -void -DelayUser::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (DelayUser); - ::operator delete (address); -} - DelayUser::DelayUser() { DelayPools::registerForUpdates (this); } static Splay<DelayUserBucket::Pointer>::SPLAYFREE DelayUserFree; DelayUser::~DelayUser() { DelayPools::deregisterForUpdates (this); @@ -142,48 +128,20 @@ DelayIdComposite::Pointer DelayUser::id(CompositePoolNode::CompositeSelectionDetails &details) { if (!details.user || !details.user->user() || !details.user->user()->username()) return new NullDelayId; debugs(77, 3, HERE << "Adding a slow-down for User '" << details.user->user()->username() << "'"); return new Id(this, details.user->user()); } -void * -DelayUser::Id::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (Id); - return ::operator new (size); -} - -void -DelayUser::Id::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (Id); - ::operator delete (address); -} - -void * -DelayUserBucket::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (DelayUserBucket); - return ::operator new (size); -} - -void -DelayUserBucket::operator delete(void *address) -{ - DelayPools::MemoryUsed -= sizeof(DelayUserBucket); - ::operator delete(address); -} - DelayUserBucket::DelayUserBucket(Auth::User::Pointer aUser) : authUser(aUser) { debugs(77, 3, "DelayUserBucket::DelayUserBucket"); } DelayUserBucket::~DelayUserBucket() { authUser = NULL; debugs(77, 3, "DelayUserBucket::~DelayUserBucket"); } === modified file 'src/DelayUser.h' --- src/DelayUser.h 2017-01-01 00:12:22 +0000 +++ src/DelayUser.h 2017-01-13 06:04:40 +0000 @@ -17,59 +17,56 @@ #include "auth/User.h" #include "CompositePoolNode.h" #include "DelayBucket.h" #include "DelayIdComposite.h" #include "DelaySpec.h" #include "splay.h" /// \ingroup DelayPoolsAPI class DelayUserBucket : public RefCountable { + MEMPROXY_CLASS(DelayUserBucket); public: typedef RefCount<DelayUserBucket> Pointer; - void *operator new(size_t); - void operator delete (void *); void stats(StoreEntry *)const; DelayUserBucket(Auth::User::Pointer); ~DelayUserBucket(); DelayBucket theBucket; Auth::User::Pointer authUser; }; /// \ingroup DelayPoolsAPI class DelayUser : public CompositePoolNode { + MEMPROXY_CLASS(DelayUser); public: typedef RefCount<DelayUser> Pointer; - void *operator new(size_t); - void operator delete (void *); DelayUser(); virtual ~DelayUser(); virtual void stats(StoreEntry * sentry); virtual void dump(StoreEntry *entry) const; virtual void update(int incr); virtual void parse(); virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &); private: /// \ingroup DelayPoolsInternal class Id:public DelayIdComposite { + MEMPROXY_CLASS(DelayUser::Id); public: - void *operator new(size_t); - void operator delete (void *); Id(RefCount<DelayUser>, Auth::User::Pointer); ~Id(); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); private: RefCount<DelayUser> theUser; DelayUserBucket::Pointer theBucket; }; === modified file 'src/DelayVector.cc' --- src/DelayVector.cc 2017-01-01 00:12:22 +0000 +++ src/DelayVector.cc 2017-01-13 06:04:40 +0000 @@ -8,34 +8,20 @@ /* DEBUG: section 77 Delay Pools */ #include "squid.h" #if USE_DELAY_POOLS #include "comm/Connection.h" #include "CommRead.h" #include "DelayVector.h" -void * -DelayVector::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (DelayVector); - return ::operator new (size); -} - -void -DelayVector::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (DelayVector); - ::operator delete (address); -} - DelayVector::DelayVector() { DelayPools::registerForUpdates (this); } DelayVector::~DelayVector() { DelayPools::deregisterForUpdates (this); } @@ -88,34 +74,20 @@ { return new Id(this, details); } void DelayVector::push_back(CompositePoolNode::Pointer aNode) { pools.push_back(aNode); } -void * -DelayVector::Id::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (Id); - return ::operator new (size); -} - -void -DelayVector::Id::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (Id); - ::operator delete (address); -} - DelayVector::Id::Id(DelayVector::Pointer aDelayVector, CompositeSelectionDetails &details) : theVector(aDelayVector) { debugs(77, 3, "DelayVector::Id::Id"); DelayVector::iterator pos = theVector->pools.begin(); while (pos != theVector->pools.end()) { ids.push_back ((*pos)->id (details)); ++pos; } } === modified file 'src/DelayVector.h' --- src/DelayVector.h 2017-01-01 00:12:22 +0000 +++ src/DelayVector.h 2017-01-13 06:04:40 +0000 @@ -9,45 +9,42 @@ #ifndef SQUID_DELAYVECTOR_H #define SQUID_DELAYVECTOR_H #if USE_DELAY_POOLS #include "CompositePoolNode.h" /// \ingroup DelayPoolsAPI class DelayVector : public CompositePoolNode { + MEMPROXY_CLASS(DelayVector); public: typedef RefCount<DelayVector> Pointer; - void *operator new(size_t); - void operator delete (void *); DelayVector(); virtual ~DelayVector(); virtual void stats(StoreEntry * sentry); virtual void dump(StoreEntry *entry) const; virtual void update(int incr); virtual void parse(); virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &); void push_back (CompositePoolNode::Pointer); private: /// \ingroup DelayPoolsInternal class Id:public DelayIdComposite { + MEMPROXY_CLASS(DelayVector::Id); public: - void *operator new(size_t); - void operator delete (void *); - Id (RefCount<DelayVector>,CompositeSelectionDetails &); ~Id(); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); virtual void delayRead(DeferredRead const &); private: RefCount<DelayVector> theVector; std::vector<DelayIdComposite::Pointer> ids; typedef std::vector<DelayIdComposite::Pointer>::iterator iterator; === modified file 'src/Makefile.am' --- src/Makefile.am 2017-01-08 05:12:44 +0000 +++ src/Makefile.am 2017-01-21 10:43:17 +0000 @@ -102,21 +102,20 @@ DelayPool.h \ DelayPools.h \ DelaySpec.cc \ DelaySpec.h \ DelayTagged.cc \ DelayTagged.h \ DelayUser.cc \ DelayUser.h \ DelayVector.cc \ DelayVector.h \ - NullDelayId.cc \ NullDelayId.h \ ClientDelayConfig.cc \ ClientDelayConfig.h if ENABLE_DELAY_POOLS DELAY_POOL_SOURCE = $(DELAY_POOL_ALL_SOURCE) else DELAY_POOL_SOURCE = endif === removed file 'src/NullDelayId.cc' --- src/NullDelayId.cc 2017-01-01 00:12:22 +0000 +++ src/NullDelayId.cc 1970-01-01 00:00:00 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (C) 1996-2017 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -/* DEBUG: section 77 Delay Pools */ - -#include "squid.h" - -#if USE_DELAY_POOLS -#include "DelayPools.h" -#include "NullDelayId.h" - -void * -NullDelayId::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (NullDelayId); - return ::operator new (size); -} - -void -NullDelayId::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (NullDelayId); - ::operator delete (address); -} - -#endif /* USE_DELAY_POOLS */ - === modified file 'src/NullDelayId.h' --- src/NullDelayId.h 2017-01-01 00:12:22 +0000 +++ src/NullDelayId.h 2017-01-13 06:04:40 +0000 @@ -5,26 +5,24 @@ * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. */ /* DEBUG: section 77 Delay Pools */ #ifndef NULLDELAYID_H #define NULLDELAYID_H #if USE_DELAY_POOLS -#include "base/RefCount.h" #include "DelayIdComposite.h" class NullDelayId : public DelayIdComposite { + MEMPROXY_CLASS(NullDelayId); public: - void *operator new(size_t); - void operator delete (void *); - virtual int bytesWanted (int minimum, int maximum) const {return max(minimum,maximum);} + virtual int bytesWanted(int low, int high) const { return max(low,high); } - virtual void bytesIn(int qty) {} + virtual void bytesIn(int) {} }; #endif #endif /* NULLDELAYID_H */ === modified file 'src/delay_pools.cc' --- src/delay_pools.cc 2017-01-01 00:12:22 +0000 +++ src/delay_pools.cc 2017-01-21 20:33:25 +0000 @@ -34,52 +34,47 @@ #include "ip/Address.h" #include "MemObject.h" #include "mgr/Registration.h" #include "NullDelayId.h" #include "SquidString.h" #include "SquidTime.h" #include "Store.h" #include "StoreClient.h" /// \ingroup DelayPoolsInternal -long DelayPools::MemoryUsed = 0; - -/// \ingroup DelayPoolsInternal class Aggregate : public CompositePoolNode { + MEMPROXY_CLASS(Aggregate); public: typedef RefCount<Aggregate> Pointer; - void *operator new(size_t); - void operator delete (void *); Aggregate(); ~Aggregate(); virtual DelaySpec *rate() {return &spec;} virtual DelaySpec const *rate() const {return &spec;} virtual void stats(StoreEntry * sentry); virtual void dump(StoreEntry *entry) const; virtual void update(int incr); virtual void parse(); virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &); private: /// \ingroup DelayPoolsInternal class AggregateId:public DelayIdComposite { + MEMPROXY_CLASS(Aggregate::AggregateId); public: - void *operator new(size_t); - void operator delete (void *); AggregateId (RefCount<Aggregate>); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); virtual void delayRead(DeferredRead const &); private: RefCount<Aggregate> theAggregate; }; friend class AggregateId; @@ -133,54 +128,47 @@ virtual char const *label() const = 0; virtual unsigned int makeKey(Ip::Address &src_addr) const = 0; DelaySpec spec; /// \ingroup DelayPoolsInternal class Id:public DelayIdComposite { + MEMPROXY_CLASS(VectorPool::Id); public: - void *operator new(size_t); - void operator delete (void *); Id (RefCount<VectorPool>, int); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); private: RefCount<VectorPool> theVector; int theIndex; }; }; /// \ingroup DelayPoolsInternal class IndividualPool : public VectorPool { - -public: - void *operator new(size_t); - void operator delete(void *); + MEMPROXY_CLASS(IndividualPool); protected: virtual char const *label() const {return "Individual";} virtual unsigned int makeKey(Ip::Address &src_addr) const; }; /// \ingroup DelayPoolsInternal class ClassCNetPool : public VectorPool { - -public: - void *operator new(size_t); - void operator delete (void *); + MEMPROXY_CLASS(ClassCNetPool); protected: virtual char const *label() const {return "Network";} virtual unsigned int makeKey (Ip::Address &src_addr) const; }; /* don't use remote storage for these */ /// \ingroup DelayPoolsInternal class ClassCBucket { @@ -228,55 +216,40 @@ DelaySpec spec; VectorMap<unsigned char, ClassCBucket> buckets; class Id; friend class ClassCHostPool::Id; /// \ingroup DelayPoolsInternal class Id:public DelayIdComposite { + MEMPROXY_CLASS(ClassCHostPool::Id); public: - void *operator new(size_t); - void operator delete (void *); Id (RefCount<ClassCHostPool>, unsigned char, unsigned char); virtual int bytesWanted (int min, int max) const; virtual void bytesIn(int qty); private: RefCount<ClassCHostPool> theClassCHost; unsigned char theNet; unsigned char theHost; }; }; void Aggregate::AggregateId::delayRead(DeferredRead const &aRead) { theAggregate->delayRead(aRead); } -void * -CommonPool::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (CommonPool); - return ::operator new (size); -} - -void -CommonPool::operator delete(void *address) -{ - DelayPools::MemoryUsed -= sizeof(CommonPool); - ::operator delete(address); -} - CommonPool * CommonPool::Factory(unsigned char _class, CompositePoolNode::Pointer& compositeCopy) { CommonPool *result = new CommonPool; switch (_class) { case 0: break; @@ -393,48 +366,20 @@ ClassCBucket::initHostIndex (DelaySpec &rate, unsigned char index, unsigned char host) { assert (!individualUsed(index)); unsigned char const newIndex = individuals.insert (host); /* give the bucket a default value */ individuals.values[newIndex].init (rate); } -void * -CompositePoolNode::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (CompositePoolNode); - return ::operator new (size); -} - -void -CompositePoolNode::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (CompositePoolNode); - ::operator delete (address); -} - -void * -Aggregate::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (Aggregate); - return ::operator new (size); -} - -void -Aggregate::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (Aggregate); - ::operator delete (address); -} - Aggregate::Aggregate() { theBucket.init (*rate()); DelayPools::registerForUpdates (this); } Aggregate::~Aggregate() { DelayPools::deregisterForUpdates (this); } @@ -475,34 +420,20 @@ DelayIdComposite::Pointer Aggregate::id(CompositeSelectionDetails &details) { if (rate()->restore_bps != -1) return new AggregateId (this); else return new NullDelayId; } -void * -Aggregate::AggregateId::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (AggregateId); - return ::operator new (size); -} - -void -Aggregate::AggregateId::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (AggregateId); - ::operator delete (address); -} - Aggregate::AggregateId::AggregateId(RefCount<Aggregate> anAggregate) : theAggregate(anAggregate) {} int Aggregate::AggregateId::bytesWanted (int min, int max) const { return theAggregate->theBucket.bytesWanted(min, max); } void @@ -530,31 +461,28 @@ } void DelayPools::InitDelayData() { if (!pools()) return; DelayPools::delay_data = new DelayPool[pools()]; - DelayPools::MemoryUsed += pools() * sizeof(DelayPool); - eventAdd("DelayPools::Update", DelayPools::Update, NULL, 1.0, 1); } void DelayPools::FreeDelayData() { eventDelete(DelayPools::Update, NULL); delete[] DelayPools::delay_data; - DelayPools::MemoryUsed -= pools() * sizeof(*DelayPools::delay_data); pools_ = 0; } void DelayPools::Update(void *unused) { if (!pools()) return; eventAdd("DelayPools::Update", Update, NULL, 1.0, 1); @@ -603,33 +531,29 @@ toUpdate.pop_back(); } } std::vector<Updateable *> DelayPools::toUpdate; void DelayPools::Stats(StoreEntry * sentry) { - unsigned short i; - storeAppendPrintf(sentry, "Delay pools configured: %d\n\n", DelayPools::pools()); - for (i = 0; i < DelayPools::pools(); ++i) { + for (unsigned short i = 0; i < DelayPools::pools(); ++i) { if (DelayPools::delay_data[i].theComposite().getRaw()) { storeAppendPrintf(sentry, "Pool: %d\n\tClass: %s\n\n", i + 1, DelayPools::delay_data[i].pool->theClassTypeLabel()); DelayPools::delay_data[i].theComposite()->stats (sentry); } else storeAppendPrintf(sentry, "\tMisconfigured pool.\n\n"); } - - storeAppendPrintf(sentry, "Memory Used: %d bytes\n", (int) DelayPools::MemoryUsed); } void DelayPools::FreePools() { if (!DelayPools::pools()) return; FreeDelayData(); } @@ -672,34 +596,20 @@ unsigned char index = findKeyIndex (key); assert (!indexUsed(index)); key_map[index] = key; ++nextMapPosition; return index; } -void * -IndividualPool::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (IndividualPool); - return ::operator new (size); -} - -void -IndividualPool::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (IndividualPool); - ::operator delete (address); -} - VectorPool::VectorPool() { DelayPools::registerForUpdates (this); } VectorPool::~VectorPool() { DelayPools::deregisterForUpdates (this); } @@ -792,34 +702,20 @@ if (keyAllocated(key)) return new Id(this, buckets.findKeyIndex(key)); unsigned char const resultIndex = buckets.insert(key); buckets.values[resultIndex].init(*rate()); return new Id(this, resultIndex); } -void * -VectorPool::Id::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (Id); - return ::operator new (size); -} - -void -VectorPool::Id::operator delete(void *address) -{ - DelayPools::MemoryUsed -= sizeof (Id); - ::operator delete (address); -} - VectorPool::Id::Id(VectorPool::Pointer aPool, int anIndex) : theVector (aPool), theIndex (anIndex) {} int VectorPool::Id::bytesWanted (int min, int max) const { return theVector->buckets.values[theIndex].bytesWanted (min, max); } void @@ -833,34 +729,20 @@ { /* IPv4 required for this pool */ if ( !src_addr.isIPv4() ) return 1; struct in_addr host; src_addr.getInAddr(host); return (ntohl(host.s_addr) & 0xff); } -void * -ClassCNetPool::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (ClassCNetPool); - return ::operator new (size); -} - -void -ClassCNetPool::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (ClassCNetPool); - ::operator delete (address); -} - unsigned int ClassCNetPool::makeKey(Ip::Address &src_addr) const { /* IPv4 required for this pool */ if ( !src_addr.isIPv4() ) return 1; struct in_addr net; src_addr.getInAddr(net); return ( (ntohl(net.s_addr) >> 8) & 0xff); @@ -972,34 +854,20 @@ if (keyAllocated (key)) netIndex = buckets.findKeyIndex(key); else netIndex = buckets.insert (key); hostIndex = buckets.values[netIndex].hostPosition (*rate(), host); return new Id (this, netIndex, hostIndex); } -void * -ClassCHostPool::Id::operator new(size_t size) -{ - DelayPools::MemoryUsed += sizeof (Id); - return ::operator new (size); -} - -void -ClassCHostPool::Id::operator delete (void *address) -{ - DelayPools::MemoryUsed -= sizeof (Id); - ::operator delete (address); -} - ClassCHostPool::Id::Id (ClassCHostPool::Pointer aPool, unsigned char aNet, unsigned char aHost) : theClassCHost (aPool), theNet (aNet), theHost (aHost) {} int ClassCHostPool::Id::bytesWanted (int min, int max) const { return theClassCHost->buckets.values[theNet].individuals.values[theHost].bytesWanted (min, max); } void
_______________________________________________ squid-dev mailing list squid-dev@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-dev