From f65f34c2fed0f0841540bbd280f3a1e6ec50a83a Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Wed, 24 Apr 2019 14:12:50 -0400 Subject: [PATCH] Limit returned MBOSnapshot size to avoid memory leaking --- src/lib/md/MBOProcessor.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/md/MBOProcessor.h b/src/lib/md/MBOProcessor.h index e6bd0213b..9962208f3 100644 --- a/src/lib/md/MBOProcessor.h +++ b/src/lib/md/MBOProcessor.h @@ -41,6 +41,13 @@ struct MBOSnapshot { void reset() { updated = utils::TimeStamp(); + constexpr int max = 256; + if (bids.size() > max) { + bids.resize(max); + } + if (asks.size() > max) { + asks.resize(max); + } bids.clear(); asks.clear(); }