[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

ADO Memory Leak

Asked by celestian in C++ Programming Language, Microsoft Visual C++

Tags: memory, leak, ado

VC++ 6.0 SP5, MDAC 2.8, W2K Pro SP3
I am developing an NT service that uploads data to a database. It will run 24/7. Because of this, memory leaks are of particular concern to me. I wrote a simple application that executes a select from a database continuously until you press a key. After starting the exe, I took a look at the task manager and saw the "mem usage" grow at a linear rate. There doesn't appear to be an upper bound to this growth.

01 #include <stdio.h>
02 #include <conio.h>
03 #import "c:\program files\common files\system\ado\msado15.dll" rename("EOF","adoEOF")
04
05 struct InitOle {
06 InitOle()  { ::CoInitialize(NULL); }
07 ~InitOle() { ::CoUninitialize();   }
08 } _init_InitOle_;
09
10 void hitdb();
11
12 int main(int argc, char* argv[])
13 {
14      bool done = false;
17      printf("\npress any key to cancel the test...");
18      do
19      {
20            if(kbhit()) done = true;
21            hitdb();
22      } while (!done);
23      getch();
24      return 0;
25 }
26
27 void hitdb()
28 {
29      try
30      {
31            ADODB::_RecordsetPtr   Rs1 = NULL;
32            Rs1.CreateInstance( __uuidof( ADODB::Recordset ) );
33            Rs1->Open( L"SELECT count(*) FROM counts",
34                  L"DSN=linestatus",
35                  ADODB::adOpenForwardOnly,
36                  ADODB::adLockReadOnly, -1 );
37            Rs1->Close();
38            Rs1 = NULL;
39      }
40      catch (_com_error &e) { printf("%s\n",e.ErrorMessage()); }
41      catch (...) { printf("Unspecified Error\n"); }
42 }

If I comment out lines 33 - 37 then there is no memory leak, leading me to believe the problem lies with ADO. Adding Rs1.Release(); to line 37.5 doesn't help. Explicitly creating a connection object doesn't help either, in fact, the leak occurs if I only open a connection to the db and nothing else. Additionally, I have tried to use a DSNless connection to avoid ODBC, but without luck. It seems that the memory used *should* return to a constant level after each call to hitdb(), but this doesn't appear to be the case.
[+][-]11/17/03 01:08 PM, ID: 9766879Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: C++ Programming Language, Microsoft Visual C++
Tags: memory, leak, ado
Sign Up Now!
Solution Provided By: Dexstar
Participating Experts: 5
Solution Grade: A
 
[+][-]11/06/03 08:51 AM, ID: 9695151Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/03 09:05 AM, ID: 9695218Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/07/03 03:47 AM, ID: 9700438Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/07/03 06:40 AM, ID: 9701395Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/07/03 08:51 AM, ID: 9702412Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/07/03 06:26 PM, ID: 9705502Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/12/03 07:59 AM, ID: 9732253Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/12/03 12:04 PM, ID: 9734165Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/14/03 12:15 PM, ID: 9750712Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/14/03 12:29 PM, ID: 9750817Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/14/03 12:55 PM, ID: 9750990Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/22/03 04:33 PM, ID: 9804532Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11/25/03 09:27 AM, ID: 9819161Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/31/04 08:21 AM, ID: 10242581Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/31/04 06:21 PM, ID: 10245073Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/07/04 02:17 PM, ID: 10300315Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93