Skip to content

Commit

Permalink
🩹 fix tracking of peak usage in MemoryManager
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Burgholzer <[email protected]>
  • Loading branch information
burgholzer committed Aug 8, 2023
1 parent 1c545ab commit a50af79
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dd/MemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ template <typename T> std::pair<T*, T*> MemoryManager<T>::getPair() {
auto* i = available->next;
available = i->next;
usedCount += 2U;
peakUsedCount = std::max(peakUsedCount, usedCount);
availableForReuseCount -= 2U;
return {r, i};
}
Expand All @@ -40,6 +41,7 @@ template <typename T> std::pair<T*, T*> MemoryManager<T>::getPair() {
auto* i = &(*chunkIt);
++chunkIt;
usedCount += 2U;
peakUsedCount = std::max(peakUsedCount, usedCount);
return {r, i};
}

Expand Down Expand Up @@ -76,6 +78,8 @@ template <typename T> void MemoryManager<T>::returnEntry(T* entry) noexcept {
entry->next = available;
available = entry;
++availableForReuseCount;
peakAvailableForReuseCount =
std::max(peakAvailableForReuseCount, availableForReuseCount);
--usedCount;
}

Expand Down Expand Up @@ -105,6 +109,7 @@ T* MemoryManager<T>::getEntryFromAvailableList() noexcept {
available = available->next;
--availableForReuseCount;
++usedCount;
peakUsedCount = std::max(peakUsedCount, usedCount);
// Reclaimed entries might have a non-zero reference count
entry->ref = 0;
return entry;
Expand All @@ -126,6 +131,7 @@ template <typename T> T* MemoryManager<T>::getEntryFromChunk() noexcept {
auto* entry = &(*chunkIt);
++chunkIt;
++usedCount;
peakUsedCount = std::max(peakUsedCount, usedCount);
return entry;
}

Expand Down

1 comment on commit a50af79

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-Linter Report ✔️

No problems need attention.

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.