Mercurial > hg > release > heapstats-2.1
changeset 220:b2dad9ff2e1b
Bug 3323: Memory for thread name leaks in thread recorder
Reviewed-by: SinTak
https://github.com/HeapStats/heapstats/pull/85
author | Yasumasa Suenaga <yasuenag@gmail.com> |
---|---|
date | Thu, 09 Feb 2017 22:04:01 +0900 |
parents | f6c76c7a8e56 |
children | aba6d9899517 |
files | ChangeLog agent/src/heapstats-engines/threadRecorder.cpp |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Feb 09 12:27:17 2017 +0900 +++ b/ChangeLog Thu Feb 09 22:04:01 2017 +0900 @@ -1,6 +1,7 @@ 2017-02-09 Yasumasa Suenaga <yasuenag@gmail.com> * Bug 3322: TClassContainer instance might be broken in multithreaded access + * Bug 3323: Memory for thread name leaks in thread recorder 2017-02-04 Yasumasa Suenaga <yasuenag@gmail.com>
--- a/agent/src/heapstats-engines/threadRecorder.cpp Thu Feb 09 12:27:17 2017 +0900 +++ b/agent/src/heapstats-engines/threadRecorder.cpp Thu Feb 09 22:04:01 2017 +0900 @@ -1,7 +1,7 @@ /*! * \iile threadRecorder.cpp * \brief Recording thread status. - * Copyright (C) 2015 Yasumasa Suenaga + * Copyright (C) 2015-2017 Yasumasa Suenaga * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -346,6 +346,19 @@ */ TThreadRecorder::~TThreadRecorder() { munmap(record_buffer, aligned_buffer_size); + + /* Deallocate memory for thread name. */ + spinLockWait(&idmapLockVal); + { + for (std::tr1::unordered_map<jlong, char *, + TNumericalHasher<jlong> >::iterator itr = + threadIDMap.begin(); + itr != threadIDMap.end(); itr++) { + free(itr->second); + } + } + spinLockRelease(&idmapLockVal); + } /*!