locked
Recordset15:Open method eats lots of Memory RRS feed

  • Question

  • Gurus,

    I am using ADO recordset and when I an trying to open the recordset, I can see a jump of 100+ MB of memory for an example before calling open function my memory was 15 MB, the moment it comes opens the recordset, the memory shoots upto 110 MB and finally when I am done and close the recordset pointer, it again comes to normal levels but I don't knwo why it shoots upto 100 MB even my no. of records are small only. When my no. of records are quite large, the memory shoots upto 1GB and at sometime I got "not enough space to perform the operation" error.

    here is my code:

    _RecordsetPtr *prs;
     _ConnectionPtr *pcn;
    bstrConnectionString = ".....some connection string......valid only..able to open the connection";

    bstrShape

    = L"SHAPE {SELECT RCID, RESOURCETYPE, STATUS, VERSION, NAME, DESCRIPTION, NTDOMAIN, SITELOCATION, PHONEEXTENSION, SYSTEMCONNECTION, LOGIN_STATUS, HARDACDROUTING, FLAGS, USEPROFILE, IP, LRMIDKEY, LRMIDNAME, PROFILENAME FROM RESPROFILEVIEWFULL WHERE RESOURCETYPE = 2 AND RCID IN (" + _bstr_t(bstrAgentIds) +_bstr_t(")} ");

    bstrShape

    += L" APPEND ((SHAPE {select RCID, CAPID, CAPNAME, DESCRIPTION, ACTID, NONPROFCAPSETS.ROLE, ACTIVATIONID, ACTNAME, LEVEL_, PROPLUS, ROLE.SEQ, ROLE.ROLE AS ROLENAME FROM NONPROFCAPSETS,ROLE WHERE ROLE.ROLE=NONPROFCAPSETS.ROLE }"

    L

    " APPEND ({Select CAPID, CATID, '' AS CATNAME, QUALID, '' AS QUALNAME FROM CAP2CATQUAL}"

    L

    " RELATE CAPID TO CAPID) AS NonProfCatQuals)"

    L

    " RELATE RCID TO RCID) AS NonProfCapsets,"

    L

    " ((SHAPE {SELECT CAPID, PROFILENAME, CAPNAME, DESCRIPTION, ACTID, PROFCAPSETS.ROLE, ACTIVATIONID, ACTNAME, LEVEL_,ROLE.SEQ,ROLE.ROLE AS ROLENAME FROM PROFCAPSETS,ROLE WHERE PROFCAPSETS.ROLE = ROLE.ROLE}"

    L

    " APPEND ({Select CAPID, CATID, '' AS CATNAME, QUALID, '' AS QUALNAME FROM CAP2CATQUAL}"

    L

    " RELATE CAPID TO CAPID) AS ProfCatQuals)"

    L

    " RELATE PROFILENAME TO PROFILENAME) AS ProfCapSets";

     

    pcn->CreateInstance(__uuidof(Connection));
    (*pcn)->Open(bstrConnectionString, (BSTR)NULL, (BSTR)NULL, -1);
    prs->CreateInstance(__uuidof(Recordset));

    // (*prs)->CacheSize = 2;

     

    (*prs)->Open(_variant_t(bstrShape ),                                    // here the memory jumps to > 1GB for large no of records.
                             _variant_t(pcn->GetInterfacePtr(), true),
                             adOpenKeyset,
                             adLockOptimistic,
                             adCmdText);

    ......operation done....
    (*prs)->Close();
    pcn->Close();

    Why it is taking such a large memory.....it is becoz my SQL string is too big?
    how can i reduce the memory hike?  apart from ADO can I use any other things to do the ame operation.

    Thx a lot in Advance
    ~Swarn


    Tuesday, November 3, 2009 8:56 AM

Answers