none
Memory Leak in CString (C++) RRS feed

  • General discussion

  •  Hi ..   I found memory leak in CString (C++) . RUN FOLLOWING CODE ON YOUR MACHINE IT GIVES U BETTER IDEA.

    CMemoryState msOld, msNew, msDif;
     
     //Obtains a snapshot or checkpoint of the current memory state.
     msOld.Checkpoint();

     CString szEmail = "bhaumik_4u@yahoo.co.in";

     msOld.DumpAllObjectsSince();
     //Obtains a snapshot or checkpoint of the current memory state.
     msNew.Checkpoint();

     //Check Difference - It should be 0 but it returns nonzero means
     //there is a leak.
     if( msDif.Difference( msOld, msNew ) ){
            TRACE( "Memory leaked!\n" );
        }else{
      TRACE( "No Memory leaked!\n" );
     }

     //Prints memory allocation statistics for a CMemoryState object
     msDif.DumpStatistics();

    thanks
    bhaumik_4u@yahoo.co.in

    Wednesday, June 4, 2008 10:27 AM