Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Problem with handle leaks...?!

Re: Problem with handle leaks...?!

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: 1 Aug 2003 05:28:00 -0700
Message-ID: <1a75df45.0308010428.5ea659c5@posting.google.com>


"Tilman Kuepper" <kuepper_at_xgraphic.de> wrote i

> With Windows 2000 the Task-Manager can be customized to show
> the number of open handles of each running process. (As well as the
> number of threads, the allocated memory and many more things...)

Ah.. forgot about that (I usually configure Performance Monitor for that).

> While the test program executes, the number of running threads increases
> and decreases as expected. But the number of open handles only
> increases; two handles with every new db connection...
>
> This "handle leak" only shows up, if the db connection is created
> by a worker thread; if I don't use threads the problem is gone...

Does not make much sense.. I assume that the db.Close() calls the destructor and that should free the handle - whether it is in the main thread or not.

There's not maybe an execption of sorts (uncaught & unnoticed) that gets raised silently, preventing the CDatabase.~destructor() from doing its job?

What happens when you simply create the db object and destroy it, without attempting a connection?  

Final thought.. in something like Delphi I have to explicitly create the object, before calling any methods.

Thus something like this:

    CDatabase db; // create a null pointer of object type     

    db = CDatabase.Create(); // <---- create the object     try // create a resource protection block       db.OpenEx("DSN=MyDSN;UID=tilli;PWD=tilli", 0);     finally
      db.Close();
    end;

What I do not see in your code is where you actually create the object.. (but then I also stay away as far as possible from C++). Using resource protection blocks is also IMO mandatory. Never rely on Windows to cleanup after you. :-)

--
Billy
Received on Fri Aug 01 2003 - 07:28:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US