stringstream causes memory link VC++ 2005?

This simple program seems to leak LOTS of memory when compiled in VC++ 2005:

int _tmain(int argc, _TCHAR* argv[])

{

for(int i = 0; i < 100000; ++i)

{

::Sleep(1);

std::basic_stringstream<TCHAR> str;

str << _T("Current iteration: ") << i;

}

return 0;

}

CRT: Multi-threaded debug or Multi-threaded

I compiled and ran the same piece of code in VC++ 2003 and I don't see ANY leaks!

Any ideas   Please help!

Thanks in advance



Answer this question

stringstream causes memory link VC++ 2005?

  • Mathiarasi

    Thanks Ayman.. I have already voted using the link. How do I contact PSS to request a private fix

    Thanks,
    Madhu.

  • PatrickRyu

    Could you please log a bug at http://lab.msdn.microsoft.com/productfeedback/default.aspx

    Thanks in advance for taking the time to log the issue!

    Thanks,
      Ayman Shoukry
      VC++ Team

  • JaceMan

    Is there any patch or workaround for this We just started moving our  environment to VC++ 2005 (from VC++ 6.0 and VC++ 7.1(2003). Without a patch
    for this issue, we will be in trouble

    Thanks,
    -Madhu.

  • Sreekanth Muralidharan

    It looks like you're right..

    From what I traced, the basic_iostream inherits from both basic_ostream and basic_istream - both of which virtually inherit from std::basic_ios, which inherits from ios_base. In ios_base::_Init(), the first line is _Ploc = 0;, and the last line is _Ploc = _NEW_CRT locale;  (this is in the file xiosbase ) - well, since _Init() gets called for basic_ostream AND basic_istream, that _Ploc pointer is shared, and gets overwritten (with the _Ploc=0 line), and assigned a new locale object - now this is SUPPOSED to be the same "global_locale" object, but it's not - it gets assigned a new locale object, and I think the original object never gets its reference count decremented, so it never gets freed...



  • Chuck Berg

    Ayman (or any VC++ team member)

    If/when the VC++ team comes up with a fix or a workaround, how can I (or anyone else who's interested in the workaround) expect to be notified   Should I continue to monitor the bug submission page

    Thanks in advance.

  • dariusj18

    As I mentioned you will have to request such patch first through PSS so that to be considered. Other wise, it might end up being fixed in the next release or service pack.

    Also, it all depends on the results of the investigations that are currently being carried.

    Thanks,
      Ayman Shoukry
      VC++ Team



  • BManager

    Thanks, mike_n.  Looks like you created a bug report as well.

    Ayman (or any MS representative),

    Any idea when we can expect to get a fix/workaround for this bug   It would suck to not be able to use stream classes (esp stringstream)!

    Thanks.

  • Asvin Ananthanarayan MSFT

    Hey Ayman

    Here's the link to bug report that mike_n created:

    http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=e08bd793-3fef-40ff-adda-ed313e0eafcc

    If you can't get to the link, the Bug ID is FDBK40119.

    Looking forward to the workaround...

    Thanks!

  • KarthikReddy

    That is correct a workaround (if exists) should be posted there once the folks look into the issue.

    If you don't see an update to the link in the next couple of days, feel free to ping me on the forums and I can take a look,

    Thanks,
      Ayman Shoukry
      VC++ Team

  • phillihp

    You can contact PPS through our suport page at http://support.microsoft.com/default.aspx.

    Make sure to let them aware of the bug link.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Stephen McCloskey

    Thanks Ayman..I will be contacting the support group for this..

    Is there emergency patch coming out for the std::iostream memory leak..

    To me its a 'show stopper'. I can't even suggest our development team to migrate to Visual C++ 2005 by knowing the fact that there is a memory leak..!!!!

    Thanks,
    Madhu.

  • F.Chen

    std::iostream memory leak - any status update yet

    This is a "cannot ship app until it's fixed" bug - is there any fix we can apply ourselves to the standard library sources until a fix is generally available   Can someone who's looked into it please make a quick post here

    Thanks
    Ted.

  • msatish

    Hi,
     Thanks for having an interest in the issue. Please use http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=e08bd793-3fef-40ff-adda-ed313e0eafcc to vote on it as well as add comments regarding needing a patch for it or a workaround. Also, you might need to contact PSS to request a private fix for it. As soon as folks look into the issue they should have more details there (at the above link)

    Once more, thanks and please keep an eye on the link. From my side, I will try to get in contact with the responsible folks and point them to the bug.

    Thanks,
      Ayman Shoukry
      VC++ Team



  • Christopher Yager

    Could you send me the bug link and I can make sure someone look at it straight ahead They should be able to provide at least a workaround.

    Thanks,
      Ayman Shoukry
      VC++ Team



  • stringstream causes memory link VC++ 2005?