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. Dynamic memomory error

Dynamic memomory error

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingperformancehelpquestion
7 Posts 5 Posters 2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    When I try clean dynamic memory using delete[] operator, message "Unhandled exception at 0x77f767cd in SDIStart.exe: User breakpoint." appears. What can cause the exception? Thanks a lot.

    T C 2 Replies Last reply
    0
    • L Lost User

      When I try clean dynamic memory using delete[] operator, message "Unhandled exception at 0x77f767cd in SDIStart.exe: User breakpoint." appears. What can cause the exception? Thanks a lot.

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      evgumin wrote: What can cause the exception? many things... give us the portion of crashing code please...


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      E 1 Reply Last reply
      0
      • L Lost User

        When I try clean dynamic memory using delete[] operator, message "Unhandled exception at 0x77f767cd in SDIStart.exe: User breakpoint." appears. What can cause the exception? Thanks a lot.

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Firsts things that comes in mind: - did you allocate the memory with new[] and not with new ? - Try to see if somewhere in your code you don't write outside the borders of your allocated memory... But, as toxxct said, post the code, this will help us a lot.

        E 1 Reply Last reply
        0
        • T toxcct

          evgumin wrote: What can cause the exception? many things... give us the portion of crashing code please...


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          E Offline
          E Offline
          evgumin
          wrote on last edited by
          #4

          There is a peace of code: void TStationArray::InitCollection() { CMegaBase base; CDBVariant** var; base.Query.Format("select STATIONNO from STATION order by STATIONNO"); if ( base.MakeSelectVar("", &var)!=-1 ) { for (int i=0; i This is a static method of the class TStationArray. Memory is occupied in calling base.MakeSelectVar("", &var). I reprsent this method below. `int CMegaBase::MakeSelectVar (CString query, CDBVariant ***vIn) { CDBVariant **v; v = NULL; CDatabase cdbMyDB; CRecordset recSet; if (query=="") query=this->Query; try { cdbMyDB.Open(server, FALSE, FALSE, initStr, FALSE); if (cdbMyDB.IsOpen ()) { recSet.m_pDatabase=&cdbMyDB; recSet.Open (CRecordset::snapshot, query, CRecordset::readOnly ); if (recSet.IsOpen ()) { int i=0,j; while (!recSet.IsEOF()) { recSet.MoveNext(); i++; } n=i; m=recSet.GetODBCFieldCount (); if (n!=0){ v = new CDBVariant*[n]; } if (!recSet.IsBOF()) { recSet.MoveFirst(); } i=0; while (!recSet.IsEOF()) { v[i]=new CDBVariant[m]; for (j=0; jm_strError +recSet.GetSQL ()); return -1; } catch (CMemoryException) { AfxMessageBox ("memExcept"); } if (vIn!=NULL) {*vIn=v;} pVar=v; return 0; }` Thanks for your help.

          W L 2 Replies Last reply
          0
          • E evgumin

            There is a peace of code: void TStationArray::InitCollection() { CMegaBase base; CDBVariant** var; base.Query.Format("select STATIONNO from STATION order by STATIONNO"); if ( base.MakeSelectVar("", &var)!=-1 ) { for (int i=0; i This is a static method of the class TStationArray. Memory is occupied in calling base.MakeSelectVar("", &var). I reprsent this method below. `int CMegaBase::MakeSelectVar (CString query, CDBVariant ***vIn) { CDBVariant **v; v = NULL; CDatabase cdbMyDB; CRecordset recSet; if (query=="") query=this->Query; try { cdbMyDB.Open(server, FALSE, FALSE, initStr, FALSE); if (cdbMyDB.IsOpen ()) { recSet.m_pDatabase=&cdbMyDB; recSet.Open (CRecordset::snapshot, query, CRecordset::readOnly ); if (recSet.IsOpen ()) { int i=0,j; while (!recSet.IsEOF()) { recSet.MoveNext(); i++; } n=i; m=recSet.GetODBCFieldCount (); if (n!=0){ v = new CDBVariant*[n]; } if (!recSet.IsBOF()) { recSet.MoveFirst(); } i=0; while (!recSet.IsEOF()) { v[i]=new CDBVariant[m]; for (j=0; jm_strError +recSet.GetSQL ()); return -1; } catch (CMemoryException) { AfxMessageBox ("memExcept"); } if (vIn!=NULL) {*vIn=v;} pVar=v; return 0; }` Thanks for your help.

            W Offline
            W Offline
            wb
            wrote on last edited by
            #5

            try using std::vector and boost::shared_ptr and not CDBVariant ***vIn :wtf:

            1 Reply Last reply
            0
            • C Cedric Moonen

              Firsts things that comes in mind: - did you allocate the memory with new[] and not with new ? - Try to see if somewhere in your code you don't write outside the borders of your allocated memory... But, as toxxct said, post the code, this will help us a lot.

              E Offline
              E Offline
              evgumin
              wrote on last edited by
              #6

              I use new[] and delete[]. Please, explain what you intended in the second advice. And I represented the code in the answer to toxxct. Thank you.

              1 Reply Last reply
              0
              • E evgumin

                There is a peace of code: void TStationArray::InitCollection() { CMegaBase base; CDBVariant** var; base.Query.Format("select STATIONNO from STATION order by STATIONNO"); if ( base.MakeSelectVar("", &var)!=-1 ) { for (int i=0; i This is a static method of the class TStationArray. Memory is occupied in calling base.MakeSelectVar("", &var). I reprsent this method below. `int CMegaBase::MakeSelectVar (CString query, CDBVariant ***vIn) { CDBVariant **v; v = NULL; CDatabase cdbMyDB; CRecordset recSet; if (query=="") query=this->Query; try { cdbMyDB.Open(server, FALSE, FALSE, initStr, FALSE); if (cdbMyDB.IsOpen ()) { recSet.m_pDatabase=&cdbMyDB; recSet.Open (CRecordset::snapshot, query, CRecordset::readOnly ); if (recSet.IsOpen ()) { int i=0,j; while (!recSet.IsEOF()) { recSet.MoveNext(); i++; } n=i; m=recSet.GetODBCFieldCount (); if (n!=0){ v = new CDBVariant*[n]; } if (!recSet.IsBOF()) { recSet.MoveFirst(); } i=0; while (!recSet.IsEOF()) { v[i]=new CDBVariant[m]; for (j=0; jm_strError +recSet.GetSQL ()); return -1; } catch (CMemoryException) { AfxMessageBox ("memExcept"); } if (vIn!=NULL) {*vIn=v;} pVar=v; return 0; }` Thanks for your help.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                "Unhandled exception at 0x77f767cd in SDIStart.exe: User breakpoint." You can see debug output there should be some explanation why that happened. Any way it seems some heap corruption occured. You can use Page Heap OS feature to try to catch where this corruption happens. To enable this feature you should use Global Flags Editor. Also you can take a look to this article http://www.codeproject.com/debug/cdbntsd3.asp[^] See http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/TechRef/b6af1963-3b75-42f2-860f-aff9354aefde.mspx[^] for more information about gflags utility. To enable Page Heap and other debugging features without gflags.exe utility add to the registry the following entries:

                [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\SDIStart.exe]
                "GlobalFlag"=dword:103099f3
                "VerifierFlags"=dword:000d3ff7
                "PageHeapFlags"=dword:00000003

                That works for Windows XP These settings will catch allocated memory overrun. Windows XP also can provide memory underrun. I always debugging my programs using this feature. WBR Henry

                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