I have a strange broblem.
i am using ADO in VC6 in a multi threading MFC application
where atleast 6-15 worker threads are executing with 2-5
user interface thread.
My problem is i have to call CoInitialize in each thread
and go for connection + record set in each thread. and
this tooks not only lot of memory but also keep incressing
as the application has to run 24h a day. By using Rational
Purifier i found 2 problems.
1. it shows memory leaks in all places where i OPEN
conection + where i set recordSet.
2. Smart pointer are unable to release auto (some
inconsistance behaviour).
3. when i debug and want to c my existing threads it not
only shows the threads of my application but also shows
the ADOs threads so its imposible to debud and trace
numbers.
Couls any one help me so thay i can stop this rise in
memory or sort of huge memory leak.
Thanks in advance
Junaid
I am using ADO in a multithreaded NT service and this approach helped me a
lot.
"Junaid" <Junai...@hotmail.com> wrote in message
news:051d01c2a665$5794c330$d3f82ecf@TK2MSFTNGXA10...
hr = CoCreateInstance(__uuidof
(ADODB::Connection),NULL,CLSCTX_INPROC_SERVER,__uuidof
(ADODB::_Connection),(void **)&pConn);
hr = pConn->Open(_bstr_t
("UID=easy;PWD=easy;DRIVER={Microsoft ODBC for
Oracle};SERVER=love;"),_bstr_t(""),_bstr_t(""),-1);
hr = CoCreateInstance(__uuidof
(ADODB::Recordset),NULL,CLSCTX_INPROC_SERVER,__uuidof
(ADODB::_Recordset),(void **)&pRstAlr);
hr = pRstAlr->Open(_bstr_t("select * from
campaign"),pConn,
ADODB::adOpenForwardOnly,ADODB::adLockReadOnly,ADODB::adCmd
Text);
int i = pRstAlr->RecordCount;
pRstAlr->Close();
pConn->Close();
pRstAlr->Release();
pConn->Release();
pRstAlr=NULL;
pConn = NULL;
CoUninitialize();
-----------
after execution the above code it don't release mem as
shown by task manager and by perfmon.
can u pls guid me where i am making this WRONG
>.
>
Any Idea????
>.
>
What resources are not being released?
ADO/ODBC libraries usually stay in (virtual) memory once they are loaded.
Try to run the part of code between CoInitialize and CoUnitialize in a loop.
Does your memory usage creeps up?
I have an application that does that and I noticed that the memory
consumption grows by 4K about every 1000 database operations. I tried
BoundsChecker and Purify and they showed no memory leaks. So I assume it is
heap fragmentation or something.
"Junaid" <Junai...@hotmail.com> wrote in message
news:046801c2a72d$5d4e61a0$d7f82ecf@TK2MSFTNGXA14...
I did a test by doing that same step a million times, but never saw the
memory grow one byte. So I have dismissed that type of error as incorrectly
reported by Rational Purify. You should do exactly the same. Take the error
that Purify is reporting, make a simple benchmark, and if you don't see
memory growing infinite, then just dismiss it.
"Junaid" <Junai...@hotmail.com> wrote in message
news:046801c2a72d$5d4e61a0$d7f82ecf@TK2MSFTNGXA14...
u comment on rational purifyer okay lets say u r right.
Now listen to me pls again it might help in identifying
the problem.
if i do the same stuf in VB and VC and monitor other
application by task monitor and perfmon i get the same
problem. the resources are not released by them. i am
using ADO 2.7 with oracle 8i.
when i get the dump of my objects i get some tace like
CDynLinkLibrary 64 bytes long xxxxxxxx
Then i search in MSDN i i find some artical i.e.
PRB: Memory Leaks Reported When Using Multiple MFC DLLs
in which it discuse things as a false leak in debug
version only but i am experiencing it in my release
version as well.
My problem is that the application i am developing has to
run on the main production server continusly 24h*30days+12
months
so i can't afford to lose even a single byte.
Plz help me if any one has any idea to solve this problem
otherwise any ROUND ABOUT.
special thanx in advance
JUNAID
>.
>
Rule number one: Not everything Purify reports as a memory leak is in
reality a memory leak.
In other words, if you get a memory leak and can't find anything wrong then
just test that structure of code by executing it a lot and watch if your
private bytes and virtual bytes of your process keep on growing until you
get memory allocation errors. If it doesn't then Purify is wrong.
"Junaid" <Junai...@hotmail.com> wrote in message
news:06ee01c2a80c$2076dd90$d2f82ecf@TK2MSFTNGXA09...
Special thx for ur help.
i would like to close this discussion and here are my
closing statmnets
1. i tried to use ADO cos i is future and it give many
features but i found is too bad (sory to use this word)
experience using it in some sensetive, performance
oriented and 7*30*12 executing time aplication.
I never ever recamund any one to use this in such an
application. it keep on incressing memmory and .... (don't
want to comment more).
Now i am usinf simple ODBC MFC classes CDatabase,
CRecordSet and it is quite stable (still have leaks but
now my app can execute atleast for 1 month countinusly).
I might not be a perfact devloper and might not understand
COM and ADO in 100% but i don't find it a good compoonent
tto use in the presence of ODBC specially in the case of
Relational DB.
Once again special thx for ur help and pressious disscusion
my mail is
Junai...@hotmail.com
i will be glad to have u friends when ever i can do some
thing for u.
BYE and happy crismiss
JUNAID
>.
>
>I am using ADO in a multithreaded NT service