Boost logo

Boost Users :

Subject: [Boost-users] [Chrono] Memory leak in Chrono?
From: Don (dm413-boost_at_[hidden])
Date: 2013-02-08 14:24:37


Boost 1.53
Chrono version 2
VC 2008
Win7-64

If I #include <boost/chrono.hpp> and run my program, on program exit the VC debugger reports about 40 memory leaks. I don't have to actually use chrono, just include the header.

A little trial-and-error with #include statements tracked this down to boost\chrono\io\duration_units.hpp. It looks like there are a couple of "new" allocations in the constructor for duration_units_default_initializer_t that are never deleted. As a test I added a destructor that did delete[] on them, and that fixed the memory leaks. However, there is some logic with the initialized_ variable in the constructor that leads me to suspect that this is not a viable solution for real code. :-)

Can anyone suggest a better solution for this? Or failing that, give me any ideas about what this code is actually doing and/or how I might proceed?

There is a good chance that someone will say "that's not a real memory leak, it's allocated once and never deleted, but it goes away when your program exits. Don't worry about it". The problem with that answer is that when you have 40 or 50 memory leaks that are "normal", everyone stops paying any attention to the memory leak report and you start adding (unintentionally) real memory leaks in your code.

Thanks for your help,
Don


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net