# HG changeset patch # User Yasumasa Suenaga # Date 1486645441 -32400 # Node ID b2dad9ff2e1b15dde37276b960bdee36c8efd1f1 # Parent f6c76c7a8e5645f5c5483a5430963e0e77082882 Bug 3323: Memory for thread name leaks in thread recorder Reviewed-by: SinTak https://github.com/HeapStats/heapstats/pull/85 diff -r f6c76c7a8e56 -r b2dad9ff2e1b ChangeLog --- 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 * 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 diff -r f6c76c7a8e56 -r b2dad9ff2e1b agent/src/heapstats-engines/threadRecorder.cpp --- 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 >::iterator itr = + threadIDMap.begin(); + itr != threadIDMap.end(); itr++) { + free(itr->second); + } + } + spinLockRelease(&idmapLockVal); + } /*!