Thread: memory leak , help please?

  1. #1
    Registered User
    Join Date
    Nov 2010

    Unhappy memory leak , help please?

    #include <iostream>
    #include <string>
    #include <deque>
    using namespace std;

    #define _CRTDBG_MAP_ALLOC
    #include <crtdbg.h>

    struct myStruct
    int i;
    string str;

    int main()
    deque <myStruct*> mine;

    myStruct* s;
    for (int i =0 ; i < 10 ; i ++)
    s = new myStruct;
    s->i = i;
    s->str = "hello" +i;

    //delete s;

    for (int i = 0; i < mine.size() ; i++)
    cout << mine[i]->i << endl;

    system( "pause" );

    as you can see its very simple . if i use the "delete s" then it will stop the memory leaks but will also make everything in mine compleatly random .

    can anyone help , or give me a link or book name to find how to fix this please

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Quote Originally Posted by thedodgeruk View Post
    can anyone help
    Sure they can

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory leak in this case?
    By George2 in forum C++ Programming
    Replies: 3
    Last Post: 03-22-2008, 05:05 AM
  2. memory leak in the code?
    By George2 in forum C++ Programming
    Replies: 20
    Last Post: 01-13-2008, 06:50 AM
  3. Is this code memory leak free? ---> POSIX Threads
    By avalanche333 in forum C++ Programming
    Replies: 9
    Last Post: 04-13-2007, 03:19 PM
  4. Any Memory Leak Checking Tool?
    By George2 in forum C Programming
    Replies: 4
    Last Post: 06-21-2006, 11:02 PM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM