Dynamic memomory error
-
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.
-
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.
Firsts things that comes in mind: - did you allocate the memory with
new[]
and not withnew
? - 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. -
evgumin wrote: What can cause the exception? many things... give us the portion of crashing code please...
TOXCCT >>> GEII power
[toxcct][VisualCalc]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.
-
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.
-
Firsts things that comes in mind: - did you allocate the memory with
new[]
and not withnew
? - 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. -
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.
"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:00000003That 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