Click here to Skip to main content
15,915,164 members
Home / Discussions / Database
   

Database

 
GeneralRe: Creating a Web Form Using a DataSet Pin
perlmunger3-Jan-05 9:40
perlmunger3-Jan-05 9:40 
GeneralWhere... Pin
KORCARI1-Jan-05 1:22
KORCARI1-Jan-05 1:22 
GeneralSQL Server does not exist or access denied Pin
nikneem200531-Dec-04 6:07
nikneem200531-Dec-04 6:07 
GeneralRe: SQL Server does not exist or access denied Pin
kings_131-Dec-04 7:51
kings_131-Dec-04 7:51 
GeneralRe: SQL Server does not exist or access denied Pin
Colin Angus Mackay31-Dec-04 15:26
Colin Angus Mackay31-Dec-04 15:26 
GeneralRe: SQL Server does not exist or access denied Pin
nikneem20051-Jan-05 4:00
nikneem20051-Jan-05 4:00 
GeneralRe: SQL Server does not exist or access denied Pin
nikneem20051-Jan-05 4:28
nikneem20051-Jan-05 4:28 
GeneralHuge Memory Consumption Pin
Developer567831-Dec-04 0:41
Developer567831-Dec-04 0:41 
Hello,

I'm developing an application in VC++ using MFC. I use MS Access as the back end. I use the following function for retrieving some data from the database. This function is called in a loop around 20 times (one query per table).

I'm observing a strange problem. The first time when the set of 20 queries are executed the total memory allocated within this function comes to around 50 MB (as shown by the Task Manager). Now, without closing the application, if I repeat the same set of queries (I can do it through a menu item) the memory allocation within the function is around 2 MB only. Now onwards, If I repeat the same set of queries any no: of times, each time the memory
allocation is only around 2 MB.

If I close the application and start it again, the same behaviour happens. That is, only the first time a huge amount of memory is consumed.

Please let me know if there is any problem with this code that causes this
strange behavior.

Thanks & Regards,
Nishanth.


int CMyDataBase::QueryRecordsFromDatabase(
CArray <CStringArray*, CStringArray*>& p_arRecordPtrs,
const CString& p_csQuery)
{
int nRetVal(0);

_RecordsetPtr pRecordSet;

try
{
pRecordSet.CreateInstance(__uuidof(Recordset));
pRecordSet->Open(_bstr_t(p_csQuery),
m_pDatabase.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic, adCmdText);

_variant_t Index;
_variant_t Indexval;
Index.vt = VT_I2;

int nTotalFields = pRecordSet->GetFields()->Count;

while(!pRecordSet->adoEOF)
{
CStringArray* pRecord = new CStringArray;

pRecord->SetSize(nTotalFields);

for (int nEachField = 0 ;
nEachField < nTotalFields; ++nEachField)
{
Index.iVal = nEachField;

Indexval =
pRecordSet->Fields->GetItem(Index)->Value;

CString csValue = (char*)_bstr_t(Indexval);
pRecord->SetAt(nEachField, csValue);
}

p_arRecordPtrs.Add(pRecord);

try
{
pRecordSet->MoveNext();
}

catch(_com_error &e)
{
m_csError = (char*) e.Description();
}
}

pRecordSet->Close();
pRecordSet.Release();

nRetVal = 1;
}

catch (_com_error &e)
{
m_csError = (char*) e.Description();
}
catch (...)
{
m_csError = "Unknown exception";
}

return nRetVal;
}

GeneralRe: Huge Memory Consumption Pin
Mike Dimmick2-Jan-05 6:16
Mike Dimmick2-Jan-05 6:16 
GeneralRe: Huge Memory Consumption Pin
Developer56783-Jan-05 2:45
Developer56783-Jan-05 2:45 
GeneralHow Pin
KORCARI31-Dec-04 0:09
KORCARI31-Dec-04 0:09 
GeneralRe: How Pin
Rob Graham31-Dec-04 3:45
Rob Graham31-Dec-04 3:45 
GeneralWhere.... Pin
KORCARI31-Dec-04 0:06
KORCARI31-Dec-04 0:06 
GeneralMySQL GRANT SELECT Pin
alex.barylski30-Dec-04 15:09
alex.barylski30-Dec-04 15:09 
GeneralRe: MySQL GRANT SELECT Pin
WoutL31-Dec-04 0:46
WoutL31-Dec-04 0:46 
GeneralRe: MySQL GRANT SELECT Pin
Colin Angus Mackay31-Dec-04 15:46
Colin Angus Mackay31-Dec-04 15:46 
GeneralTOPLESS LADIES INSIDE - SQL Pin
HarryBo30-Dec-04 9:10
HarryBo30-Dec-04 9:10 
GeneralRe: TOPLESS LADIES INSIDE - SQL Pin
Javier Lozano1-Jan-05 13:44
Javier Lozano1-Jan-05 13:44 
GeneralOracle forms 6i problem Pin
missnazar30-Dec-04 4:00
missnazar30-Dec-04 4:00 
GeneralStored Procedure PRoblem Pin
percyvimal30-Dec-04 2:15
percyvimal30-Dec-04 2:15 
GeneralRe: Stored Procedure PRoblem Pin
Mike Dimmick30-Dec-04 3:50
Mike Dimmick30-Dec-04 3:50 
GeneralRe: Stored Procedure PRoblem Pin
abbaskaya30-Dec-04 4:29
abbaskaya30-Dec-04 4:29 
GeneralRe: Stored Procedure PRoblem Pin
abbaskaya30-Dec-04 4:30
abbaskaya30-Dec-04 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.