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. Database & SysAdmin
  3. Database
  4. ADO Memory usage - leak?

ADO Memory usage - leak?

Scheduled Pinned Locked Moved Database
announcementc++performancehelpquestion
2 Posts 2 Posters 0 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.
  • G Offline
    G Offline
    Gizz
    wrote on last edited by
    #1

    Hi. I've got a basic ADO AddNew call, running in a loop, against Access 2002. Running on VC++6, Win2K, MDAC 6 sp2. See code below. It seems to use memory constantly, even when the recordset object is released. It uses approx 10MB per 100,000 rows written. My system needs to be on line and writing data for a week at a time so this is going to be a problem for me. Any ideas? Ta. Gizz. The following function is called from another big loop... void fn() { using namespace ADODB; _RecordsetPtr pRst = NULL; _ConnectionPtr pConnection = NULL; _bstr_t strCnn("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\data.MDB"); try { TESTHR(pConnection.CreateInstance(__uuidof(Connection))); pConnection->Open(strCnn,"","",adConnectUnspecified); TESTHR(pRst.CreateInstance(__uuidof(Recordset))); pRst->Open("tblMyTable",_variant_t((IDispatch *) pConnection, true), adOpenKeyset,adLockOptimistic,adCmdTable); _variant_t strGBID("GBID"); _variant_t strTSID("TimestampID"); static long i = 0; static long imax = 1000; for (;i < imax; i++) { pRst->AddNew(); {_variant_t vtFld; vtFld.vt = VT_I4; vtFld.lVal = i; pRst->Fields->GetItem(strGBID)->Value = vtFld;} {_variant_t vtFld; vtFld.vt = VT_I4; vtFld.lVal = i+1; pRst->Fields->GetItem(strTSID)->Value = vtFld;} pRst->Update(); } imax += 1000; pRst->Close(); pConnection->Close(); pConnection.Release(); pRst.Release(); } catch(_com_error &) {} }

    M 1 Reply Last reply
    0
    • G Gizz

      Hi. I've got a basic ADO AddNew call, running in a loop, against Access 2002. Running on VC++6, Win2K, MDAC 6 sp2. See code below. It seems to use memory constantly, even when the recordset object is released. It uses approx 10MB per 100,000 rows written. My system needs to be on line and writing data for a week at a time so this is going to be a problem for me. Any ideas? Ta. Gizz. The following function is called from another big loop... void fn() { using namespace ADODB; _RecordsetPtr pRst = NULL; _ConnectionPtr pConnection = NULL; _bstr_t strCnn("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\data.MDB"); try { TESTHR(pConnection.CreateInstance(__uuidof(Connection))); pConnection->Open(strCnn,"","",adConnectUnspecified); TESTHR(pRst.CreateInstance(__uuidof(Recordset))); pRst->Open("tblMyTable",_variant_t((IDispatch *) pConnection, true), adOpenKeyset,adLockOptimistic,adCmdTable); _variant_t strGBID("GBID"); _variant_t strTSID("TimestampID"); static long i = 0; static long imax = 1000; for (;i < imax; i++) { pRst->AddNew(); {_variant_t vtFld; vtFld.vt = VT_I4; vtFld.lVal = i; pRst->Fields->GetItem(strGBID)->Value = vtFld;} {_variant_t vtFld; vtFld.vt = VT_I4; vtFld.lVal = i+1; pRst->Fields->GetItem(strTSID)->Value = vtFld;} pRst->Update(); } imax += 1000; pRst->Close(); pConnection->Close(); pConnection.Release(); pRst.Release(); } catch(_com_error &) {} }

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      I don't know where is the problem,But about pConnection.Release(); and pRst.Release(); I have to say you don't need them because you use these inrefaces as an pointer and they will release automaticlly. But you problem MAYBE because of access,I know it has limitation on number of records,and after you insert 100,000 rows in a table in crash or ....You didn't which line cause memory leak! Mazy "And the carpet needs a haircut, and the spotlight looks like a prison break And the telephone's out of cigarettes, and the balcony is on the make And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits

      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