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. General Programming
  3. C / C++ / MFC
  4. STL leaks ?

STL leaks ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++sharepointioshelpquestion
3 Posts 2 Posters 0 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.
  • P Offline
    P Offline
    pba_
    wrote on last edited by
    #1

    Does anybody have any idea why this program leaks ? It's a problem with STL or what ? I'm using VC++ 6.0, SP 5, W2K #include #include using namespace std; void test() { fstream fs("dbg.txt", ios::out); fs.close(); } void main(void) { test(); _CrtDumpMemoryLeaks(); }

    E 1 Reply Last reply
    0
    • P pba_

      Does anybody have any idea why this program leaks ? It's a problem with STL or what ? I'm using VC++ 6.0, SP 5, W2K #include #include using namespace std; void test() { fstream fs("dbg.txt", ios::out); fs.close(); } void main(void) { test(); _CrtDumpMemoryLeaks(); }

      E Offline
      E Offline
      Erik Funkenbusch
      wrote on last edited by
      #2

      It doesn't leak. The problem (if you can call it that) is that _CrtDumpMemoryLeaks is being called before global object destruction, thus it thinks there is a leak when the object is really destroyed afterwards. -- Where are we going? And why am I in this handbasket?

      P 1 Reply Last reply
      0
      • E Erik Funkenbusch

        It doesn't leak. The problem (if you can call it that) is that _CrtDumpMemoryLeaks is being called before global object destruction, thus it thinks there is a leak when the object is really destroyed afterwards. -- Where are we going? And why am I in this handbasket?

        P Offline
        P Offline
        pba_
        wrote on last edited by
        #3

        So STL has global objects ? (besides cin,cout and cerr ). Because I don't have any global objects ( that's my concern - the fstream object is created on the stack , so it's destroyed before I call _CrtDumpMemoryLeaks) . If it has, do you have any idea, are these objects thread safe ? And can you name some ?

        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