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: OCIEnvInit() and heavy memmory leaks

Re: OCIEnvInit() and heavy memmory leaks

From: KM <KM_at_nospam.nospam.com>
Date: Wed, 15 Mar 2006 12:01:57 +0530
Message-ID: <jOORf.40$O94.125@news.oracle.com>


Instead of OCITerminate, you should do OCIHandleFree (...Env..)

-KM.

Herode wrote:
> Hi gentlemen,
>
> here is a simplified piece of code for testing resource management :
>
> 1 - the allocation and de-allocation methods :
>
> class COCIEnvironment {
> bool COCIEnvironment::Initialize( BOOL bThreaded )
> {
> m_initMode = bThreaded ? OCI_THREADED : OCI_DEFAULT;
> m_initMode |= OCI_OBJECT;
>
> // Allocation of handle m_pEnv
> ::OCIEnvCreate( &m_pEnv, m_initMode, NULL, NULL, NULL, NULL, 0, NULL
> );
>
> // Allocation of an error handle
> ::OCIHandleAlloc( m_pEnv, reinterpret_cast< void** >( &m_pErr ),
> OCI_HTYPE_ERROR, 0, NULL );
> return true;
> }
>
> void COCIEnvironment::Terminate()
> {
> ::OCIHandleFree( m_pErr, OCI_HTYPE_ERROR );
> ::OCITerminate( m_initMode );
> m_pEnv = NULL;
> m_pErr = NULL;
> }
> [...]
> };
>
> 2 - the test code :
> COCIEnvironment env;
> cout << "Construction OCIEnvironment" << endl;
>
> for ( int i = 0; i < 20000; ++ i ) {
> env.Initialize();
> env.Terminate();
> }
>
> While performing this loop, the system available memory dramatically
> falls. I loose some 700 Mo in a few seconds. Hence, I suspect heavy
> leaks in the above code, but I am definitely unable to find and explain
> them.
>
> Have you some clues to help me ?
>
Received on Wed Mar 15 2006 - 00:31:57 CST

Original text of this message

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