mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 15:23:02 +01:00
Implemented CORE-1751. The changes include:
1) Make memory counters aggregated. 2) Add attachment pool and allocate appropriate resources out of this pool. 3) Always release attachments explicitly (via destructor). 4) Always delete user requests prior to attachment deletion. 5) Introduce memory usage counters per every monitoring object. 6) Misc refactoring. Some pieces are still incomplete (although everything basically works), but I'd like to get feedback and testing sooner rather than later.
This commit is contained in:
parent
1485094eed
commit
6a593eca17
@ -213,29 +213,41 @@ static void print_block(FILE *file, MemoryBlock *blk, bool used_only,
|
||||
|
||||
inline void MemoryPool::increment_usage(size_t size)
|
||||
{
|
||||
size_t temp = stats->mst_usage += size;
|
||||
if (temp > stats->mst_max_usage)
|
||||
stats->mst_max_usage = temp;
|
||||
for (MemoryStats* statistics = stats; statistics; statistics = statistics->mst_parent)
|
||||
{
|
||||
size_t temp = statistics->mst_usage += size;
|
||||
if (temp > statistics->mst_max_usage)
|
||||
statistics->mst_max_usage = temp;
|
||||
}
|
||||
used_memory += size;
|
||||
}
|
||||
|
||||
inline void MemoryPool::decrement_usage(size_t size)
|
||||
{
|
||||
stats->mst_usage -= size;
|
||||
for (MemoryStats* statistics = stats; statistics; statistics = statistics->mst_parent)
|
||||
{
|
||||
statistics->mst_usage -= size;
|
||||
}
|
||||
used_memory -= size;
|
||||
}
|
||||
|
||||
inline void MemoryPool::increment_mapping(size_t size)
|
||||
{
|
||||
size_t temp = stats->mst_mapped += size;
|
||||
if (temp > stats->mst_max_mapped)
|
||||
stats->mst_max_mapped = temp;
|
||||
for (MemoryStats* statistics = stats; statistics; statistics = statistics->mst_parent)
|
||||
{
|
||||
size_t temp = statistics->mst_mapped += size;
|
||||
if (temp > statistics->mst_max_mapped)
|
||||
statistics->mst_max_mapped = temp;
|
||||
}
|
||||
mapped_memory += size;
|
||||
}
|
||||
|
||||
inline void MemoryPool::decrement_mapping(size_t size)
|
||||
{
|
||||
stats->mst_mapped -= size;
|
||||
for (MemoryStats* statistics = stats; statistics; statistics = statistics->mst_parent)
|
||||
{
|
||||
statistics->mst_mapped -= size;
|
||||
}
|
||||
mapped_memory -= size;
|
||||
}
|
||||
|
||||
|
@ -170,15 +170,24 @@ struct PendingFreeBlock
|
||||
class MemoryStats
|
||||
{
|
||||
public:
|
||||
MemoryStats() : mst_usage(0), mst_mapped(0), mst_max_usage(0), mst_max_mapped(0) {}
|
||||
~MemoryStats() {}
|
||||
size_t get_current_usage() const { return mst_usage.value(); }
|
||||
size_t get_maximum_usage() const { return mst_max_usage; }
|
||||
size_t get_current_mapping() const { return mst_mapped.value(); }
|
||||
size_t get_maximum_mapping() const { return mst_max_mapped; }
|
||||
explicit MemoryStats(MemoryStats* parent = NULL)
|
||||
: mst_parent(parent), mst_usage(0), mst_mapped(0), mst_max_usage(0), mst_max_mapped(0)
|
||||
{}
|
||||
|
||||
~MemoryStats()
|
||||
{}
|
||||
|
||||
size_t getCurrentUsage() const { return mst_usage.value(); }
|
||||
size_t getMaximumUsage() const { return mst_max_usage; }
|
||||
size_t getCurrentMapping() const { return mst_mapped.value(); }
|
||||
size_t getMaximumMapping() const { return mst_max_mapped; }
|
||||
|
||||
private:
|
||||
// Forbid copy constructor
|
||||
MemoryStats(const MemoryStats& object) {}
|
||||
// Forbid copying/assignment
|
||||
MemoryStats(const MemoryStats&);
|
||||
MemoryStats& operator=(const MemoryStats&);
|
||||
|
||||
MemoryStats* mst_parent;
|
||||
|
||||
// Currently allocated memory (without allocator overhead)
|
||||
// Useful for monitoring engine memory leaks
|
||||
|
Loading…
Reference in New Issue
Block a user