Boost logo

Boost Users :

From: Josue Gomes (josue.gomes.honeypot_at_[hidden])
Date: 2006-01-30 16:47:53


Hi,

I'm experiencing a memory leak while using lexical_cast with VC8.
The leak was detected by an end-user in a long-running application and evidenced
with GlowCode (a leak detection tool).
The origin seems to be an allocation inside ios_base (<xiosbase>).

Source code for the test:

#include <string>
#include <boost/lexical_cast.hpp>

int main()
{
  std::string s = "1234";
  unsigned u = boost::lexical_cast<unsigned>(s);
}

GlowCode trace:

 Handle 0x1555308 (0x1555308 = HeapAlloc( 0x310000, 0x0, 40))
  caller(1): malloc_base(); + 236 bytes; module MSVCR80D.dll; 0x1024DB9C
  caller(2): malloc_dbg(); + 725 bytes; module MSVCR80D.dll; 0x1020FAA5
  caller(3): malloc_dbg(); + 105 bytes; module MSVCR80D.dll; 0x1020F839
  caller(4): malloc_dbg(); + 31 bytes; module MSVCR80D.dll; 0x1020F7EF
  caller(5): operator new(); + 30 bytes; module MSVCP80D.dll; 0x104F938E
  caller(6): std::ios_base::_Init(); + 112 bytes; module
MSVCP80D.dll; 0x104877B0
  caller(7): std::basic_ios<char,std::char_traits<char> >::init(); +
15 bytes; module MSVCP80D.dll; 0x10497CFF
  caller(8): std::basic_istream<char,std::char_traits<char>
>::basic_istream<char,std::char_traits<char> >(); + 143 bytes; module
MSVCP80D.dll; 0x10497F1F
  caller(9): std::basic_iostream<char,std::char_traits<char>
>::basic_iostream<char,std::char_traits<char> >(); + 115 bytes;
module MSVCP80D.dll; 0x104C9693
  caller(10): std::basic_stringstream<char,std::char_traits<char>,std::allocator<char>
>::basic_stringstream<char,std::char_traits<char>,std::allocator<char>
>(); + 116 bytes; module MSVCP80D.dll; 0x104CD2A4
  caller(11): boost::detail::lexical_stream<unsigned
int,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >::lexical_stream<unsigned
int,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >(); file e:\projects\libraries\boost_1_33_1\boost\lexical_cast.hpp;
line 134 + 81 bytes; module mleak.exe; 0x411A41
  caller(12): boost::lexical_cast<unsigned
int,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >(); file e:\projects\libraries\boost_1_33_1\boost\lexical_cast.hpp;
line 219 + 11 bytes; module mleak.exe; 0x4116BF
  caller(13): main(); file e:\projects\mleak\mleak.cpp; line 7 + 9
bytes; module mleak.exe; 0x41159E
  caller(14): __tmainCRTStartup(); file
f:\rtm\vctools\crt_bld\self_x86\crt\src\crtexe.c; line 586 + 25 bytes;
module mleak.exe; 0x412EA6
  caller(15): mainCRTStartup(); file
f:\rtm\vctools\crt_bld\self_x86\crt\src\crtexe.c; line 403, module
mleak.exe; 0x412CED

Regards,
Josue Gomes


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