Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
allocationtracker.h
Go to the documentation of this file.
1 
18 #ifndef ION_BASE_ALLOCATIONTRACKER_H_
19 #define ION_BASE_ALLOCATIONTRACKER_H_
20 
21 #include "ion/base/shareable.h"
22 #include "ion/base/sharedptr.h"
23 
24 namespace ion {
25 namespace base {
26 
27 class Allocator;
28 class AllocationSizeTracker;
29 typedef SharedPtr<AllocationSizeTracker> AllocationSizeTrackerPtr;
30 
34 class AllocationTracker : public Shareable {
35  public:
39  virtual void TrackAllocation(const Allocator& allocator,
40  size_t requested_size, const void* memory) = 0;
41 
45  virtual void TrackDeallocation(const Allocator& allocator,
46  const void* memory) = 0;
47 
49  virtual size_t GetAllocationCount() = 0;
50  virtual size_t GetDeallocationCount() = 0;
51 
55  virtual size_t GetAllocatedBytesCount() = 0;
56  virtual size_t GetDeallocatedBytesCount() = 0;
57 
61  virtual size_t GetActiveAllocationCount() = 0;
62  virtual size_t GetActiveAllocationBytesCount() = 0;
63 
66  virtual void SetGpuTracker(const AllocationSizeTrackerPtr& gpu_tracker) = 0;
68 };
69 
72 
73 } // namespace base
74 } // namespace ion
75 
76 #endif // ION_BASE_ALLOCATIONTRACKER_H_
AllocationTracker is an abstract base class for objects that track memory.
virtual size_t GetAllocatedBytesCount()=0
Returns the total number of memory ever allocated or deallocated, in bytes.
SharedPtr< AllocationSizeTracker > AllocationSizeTrackerPtr
Convenience typedef for shared pointer to a AllocationSizeTracker.
virtual size_t GetDeallocatedBytesCount()=0
virtual size_t GetActiveAllocationCount()=0
Returns the number of active allocations or the amount of memory in bytes used by active allocations...
Shareable is an abstract base class for any object that can be shared via the SharedPtr class...
Definition: shareable.h:31
SharedPtr< AllocationTracker > AllocationTrackerPtr
Convenience typedef for shared pointer to an AllocationTracker.
virtual void TrackDeallocation(const Allocator &allocator, const void *memory)=0
TrackDeallocation() is called immediately before an Allocator deallocates memory. ...
Allocator is an abstract base class for a memory allocator used for Ion objects derived from Allocata...
Definition: allocator.h:61
virtual size_t GetActiveAllocationBytesCount()=0
virtual void SetGpuTracker(const AllocationSizeTrackerPtr &gpu_tracker)=0
Sets/returns an AllocationSizeTracker instance used to track GPU memory allocations.
virtual void TrackAllocation(const Allocator &allocator, size_t requested_size, const void *memory)=0
TrackAllocation() is called immediately after an Allocator allocates memory.
virtual size_t GetDeallocationCount()=0
virtual AllocationSizeTrackerPtr GetGpuTracker()=0
virtual size_t GetAllocationCount()=0
Returns the total number of tracked allocations or deallocations.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Definition: sharedptr.h:60