From f6474f5717d61257ae299dad3f95628547f49b46 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 20 Jan 2015 16:15:45 +0000 Subject: [PATCH] fix wakeup profiling to not grow memory usage indefinitely --- include/libtorrent/debug.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/libtorrent/debug.hpp b/include/libtorrent/debug.hpp index 8d1ada442..12576de52 100644 --- a/include/libtorrent/debug.hpp +++ b/include/libtorrent/debug.hpp @@ -111,9 +111,14 @@ namespace libtorrent async_t& a = _async_ops[name]; TORRENT_ASSERT(a.refs > 0); --a.refs; - _wakeups.push_back(wakeup_t()); - wakeup_t& w = _wakeups.back(); - w.timestamp = time_now_hires(); + + // don't let this grow indefinitely + if (_wakeups.size() < 100000) + { + _wakeups.push_back(wakeup_t()); + wakeup_t& w = _wakeups.back(); + w.timestamp = time_now_hires(); + } #ifdef __MACH__ task_events_info teinfo; mach_msg_type_number_t t_info_count = TASK_EVENTS_INFO_COUNT;