15 #include <vsg/core/Export.h>
28 MEMORY_TRACKING_NO_CHECKS = 0,
29 MEMORY_TRACKING_REPORT_ACTIONS = 1,
30 MEMORY_TRACKING_CHECK_ACTIONS = 2,
31 MEMORY_TRACKING_DEFAULT = MEMORY_TRACKING_NO_CHECKS
38 explicit MemorySlots(
size_t availableMemorySize,
int in_memoryTracking = MEMORY_TRACKING_DEFAULT);
41 using OptionalOffset = std::pair<bool, size_t>;
42 OptionalOffset reserve(
size_t size,
size_t alignment);
44 bool release(
size_t offset,
size_t size);
46 bool full()
const {
return _availableMemory.empty(); }
47 bool empty()
const {
return totalAvailableSize() == totalMemorySize(); }
49 size_t maximumAvailableSpace()
const {
return _availableMemory.empty() ? 0 : _availableMemory.rbegin()->first; }
50 size_t totalAvailableSize()
const;
51 size_t totalReservedSize()
const;
52 size_t totalMemorySize()
const {
return _totalMemorySize; }
55 void report(std::ostream& out)
const;
58 mutable int memoryTracking = MEMORY_TRACKING_DEFAULT;
61 std::multimap<size_t, size_t> _availableMemory;
62 std::map<size_t, size_t> _offsetSizes;
63 std::map<size_t, size_t> _reservedMemory;
65 void insertAvailableSlot(
size_t offset,
size_t size);
66 void removeAvailableSlot(
size_t offset,
size_t size);
68 size_t _totalMemorySize;
Definition: MemorySlots.h:36