Skip to content

Commit 71cb208

Browse files
cbrown350claude
andcommitted
fix(stability): cap history buffer on allocation failure instead of silently dropping data
When vector push_back fails due to heap fragmentation, cap maxSize to current buffer size and switch to circular overwrite mode. Previously, every subsequent addPoint call would also fail silently, stopping all historical data recording permanently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d24b9c1 commit 71cb208

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/HistoricalDataManager/HistoricalDataManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ void HistoricalDataManager::addPoint(const DataPoint& point) {
4949
try {
5050
buffer.push_back(point);
5151
} catch (...) {
52-
// Allocation failed — skip this data point rather than crash
52+
// Allocation failed — cap maxSize so we switch to circular
53+
// overwrite mode instead of silently dropping all future points
54+
maxSize = buffer.size();
55+
if (maxSize == 0) return;
56+
buffer[currentIndex] = point;
57+
currentIndex = (currentIndex + 1) % maxSize;
5358
return;
5459
}
5560
} else {

0 commit comments

Comments
 (0)