Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. std::basic_stringstream

std::basic_stringstream

Scheduled Pinned Locked Moved Clever Code
debuggingc++comsysadminperformance
4 Posts 4 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    megaadam
    wrote on last edited by
    #1

    Memory leaks can nasty little buggers. X| They can give you a bad itch for a long time, but you cannot locate the itch exactly. We have had an interesting case recently, and forgive me if this is a repost: Our application, ( a mobile connection manager ), was leaking slowly but steadily. After a leaving it on during the night memory usage multiplied. Now, the first odd thing was that the debugger never detected any leaks on exit. Our first assumption was naturally that one of our objects was growing but that it was destroyed properly. After a few days we had narrowed the “leak” down to the usage monitor ( the class reporting network traffic ). But there the trail went cold. We could see nothing wrong with those few lines of code. Then we observed the next odd fact, it was only growing in the debug build ( but not release! ). Finally it turned out that the culprit was not our code at all, it was STL! ( the Microsoft implementation of it ) std::basic_stringstream< wchar_t > stream; // This leaks Here is a discussion on the MSDN forum. Apparently this has been fixed in SP1 for VS8. Two things though are beyond my comprehension, and I would be happy to learn something new: 1. How is it possible that the leaks go undetected by the debugger ? 2. A lot of people have discussed this bug on the web, but no-one mentions any difference between release & debug. :confused: MS even mentions the release of new runtime libraries with the service pack. How come I do not get this leak in release build ? Cheerz & Thanks Adam

    _____________________________________ Action without thought is not action Action without emotion is not life

    S 1 Reply Last reply
    0
    • M megaadam

      Memory leaks can nasty little buggers. X| They can give you a bad itch for a long time, but you cannot locate the itch exactly. We have had an interesting case recently, and forgive me if this is a repost: Our application, ( a mobile connection manager ), was leaking slowly but steadily. After a leaving it on during the night memory usage multiplied. Now, the first odd thing was that the debugger never detected any leaks on exit. Our first assumption was naturally that one of our objects was growing but that it was destroyed properly. After a few days we had narrowed the “leak” down to the usage monitor ( the class reporting network traffic ). But there the trail went cold. We could see nothing wrong with those few lines of code. Then we observed the next odd fact, it was only growing in the debug build ( but not release! ). Finally it turned out that the culprit was not our code at all, it was STL! ( the Microsoft implementation of it ) std::basic_stringstream< wchar_t > stream; // This leaks Here is a discussion on the MSDN forum. Apparently this has been fixed in SP1 for VS8. Two things though are beyond my comprehension, and I would be happy to learn something new: 1. How is it possible that the leaks go undetected by the debugger ? 2. A lot of people have discussed this bug on the web, but no-one mentions any difference between release & debug. :confused: MS even mentions the release of new runtime libraries with the service pack. How come I do not get this leak in release build ? Cheerz & Thanks Adam

      _____________________________________ Action without thought is not action Action without emotion is not life

      S Offline
      S Offline
      Sebastian Schneider
      wrote on last edited by
      #2

      Actually, I was fooled by the same leak. Only that I believed that "something as important as stringstream can't leak", so I dismissed that thought and happily looked for the leak in all my code. Until I thought that maybe checking it out on the web couldn't hurt - et voila, it WAS stringstream and it WAS leaking. Someone took the time of dissecting the standard implementation and posting an explanation of the leak somewhere. If I can find it again, I will post it here.

      Cheers, Sebastian -- Contra vim mortem non est medicamen in hortem.

      S 1 Reply Last reply
      0
      • S Sebastian Schneider

        Actually, I was fooled by the same leak. Only that I believed that "something as important as stringstream can't leak", so I dismissed that thought and happily looked for the leak in all my code. Until I thought that maybe checking it out on the web couldn't hurt - et voila, it WAS stringstream and it WAS leaking. Someone took the time of dissecting the standard implementation and posting an explanation of the leak somewhere. If I can find it again, I will post it here.

        Cheers, Sebastian -- Contra vim mortem non est medicamen in hortem.

        S Offline
        S Offline
        Sceptic Mole
        wrote on last edited by
        #3

        Sebastian Schneider wrote:

        Actually, I was fooled by the same leak. Only that I believed that "something as important as stringstream can't leak", so I dismissed that thought and happily looked for the leak in all my code. Until I thought that maybe checking it out on the web couldn't hurt - et voila, it WAS stringstream and it WAS leaking.

        MS never payed much attention to the std:: stuff. For them MFC was (still is and will be) the 'Standard' C++ library.

        M 1 Reply Last reply
        0
        • S Sceptic Mole

          Sebastian Schneider wrote:

          Actually, I was fooled by the same leak. Only that I believed that "something as important as stringstream can't leak", so I dismissed that thought and happily looked for the leak in all my code. Until I thought that maybe checking it out on the web couldn't hurt - et voila, it WAS stringstream and it WAS leaking.

          MS never payed much attention to the std:: stuff. For them MFC was (still is and will be) the 'Standard' C++ library.

          M Offline
          M Offline
          Magnus Westin
          wrote on last edited by
          #4

          Well, that might have been true with VS 6.0, where STL was abyssal. But since 2003 and definitely since 2005 STL and the compilers template implementation is one of the best (not the best, mind you, but ahead of most of the competition). Magnus

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups