Programming Tips - In Borland C++ 5.02 std::string is leaking handles. How can I stop this?
Product: Borland C++ 5.02
Q. In Borland C++ 5.02 std::string is leaking handles. How can I stop this?
A. Its not freeing up the string's mutex when the string is freed.
Make these changes in C:\BC5\include ...
In stdmutex.h, rename destructor of ~RWSTDMutex() to destroy()
and make a new ~RWSTDMutex() which just calls destroy.
In string.h line 1253, add a call to mutex_.destroy() ...
template <class charT, class traits, class Allocator >
inline void string_ref<charT, traits, Allocator>::unLink(Allocator& alloc)
if (removeReference() == 0)
// begin dave fix
// end dave fix
Note that even after this fix, a mutex is allocated for each std::string
which seems excessive to me.