Boost logo

Boost :

From: Kevin Bluck (kevin.bluck_at_[hidden])
Date: 2006-02-10 01:19:28


Recently I took up with the thread library. Using MSVC, I quickly ran afoul
of a memory leak report from the CRT debugger. Naturally assuming that I am
more likely to screw up than a well-reviewed library, I spent a not
insignificant amount of effort trying to track down my own stupid mistake.
Eventually realizing the cause was in boost.thread, I spent more time
researching and finally discovering this thread:
http://lists.boost.org/boost-users/2005/08/13538.php Apparently, this issue
is well understood and the consensus is that it is benign and the CRT is
just being overly pedantic.

Although I understand that the issue is generally not regarded as a bug or
even a "memory leak" as such, I can't help but imagine that other library
users are in the same boat as me. I decided it would be nice if MSVC didn't
unnecessarily alarm ignorant newcomers like myself and continually annoy
others who understand the issue but have a personal conviction against
allowing lint in their builds. So, if there is no plan to change the
underlying issue, I figured I could at least shut up MSVC.

Attached is a patch for tss_hook.cpp, which uses the function _CrtSetDbgFlag
to temporarily turn off heap allocation tracking for the particular
allocation in question. It should have no effect except on MSVC debug
builds. On my configuration (msvc-8_0) it successfully eliminates the leak
warnings. I figure it's the moral equivalent of suppressing a warning that
can't reasonably be eliminated otherwise.

I hope it seems useful.

--- Kevin




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk