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: Memory leaks on OCIEnvCreate ?

Re: Memory leaks on OCIEnvCreate ?

From: Amogh <amogh.r_at_nospam.com>
Date: Wed, 26 Apr 2006 15:44:18 +0530
Message-ID: <q%H3g.14$Fk3.24@news.oracle.com>


Herode wrote:
> Gentlemen,
>
> Here is my test code :
>
> // 1 - the loop testing the leaks
> void TestOCIEnv::test()
> {
> for ( int i = 0; i < 10000; ++ i ) {
> COCIEnvironment env;
> env.Initialize();
> }
> }
>
> // 2 - the invoked methods
> COCIEnvironment::~COCIEnvironment()
> {
> if ( ! m_pEnv ) return;
> Terminate();
> }
>
> bool COCIEnvironment::Initialize( BOOL bThreaded ) // default = FALSE
> {
> m_initMode = bThreaded ? OCI_THREADED : OCI_DEFAULT;
> m_initMode |= OCI_OBJECT;
>
> sword st = ::OCIEnvCreate( &m_pEnv, m_initMode, NULL, NULL, NULL, NULL,
> 0, NULL );
> if ( st != OCI_SUCCESS && st != OCI_SUCCESS_WITH_INFO ) {
> return false;
> }
>
> st = ::OCIHandleAlloc( m_pEnv, reinterpret_cast< void** >( &m_pErr ),
> OCI_HTYPE_ERROR, 0, NULL );
> if ( st != OCI_SUCCESS && st != OCI_SUCCESS_WITH_INFO ) {
> m_pErr = NULL;
> return false;
> }
>
> return true;
> }
>
> void COCIEnvironment::Terminate()
> {
> ::OCITerminate( m_initMode );
> ::OCIHandleFree( m_pErr, OCI_HTYPE_ERROR );
> ::OCIHandleFree( m_pErr, OCI_HTYPE_ENV );
> m_pEnv = NULL;
> m_pErr = NULL;
> }
>
> I start the loop with 352Mo memory loaded, and I end it with > 1Go...
> Whether I comment or not the OCITerminate() or the OCIHandleFree( env )
> calls does not make any difference.
>
> Could you tell me what I'm missing ?
>
> Regards,
> C.
>

 > // 1 - the loop testing the leaks
 > void TestOCIEnv::test()
 > {
 > for ( int i = 0; i < 10000; ++ i ) {
 > COCIEnvironment env;
 > env.Initialize();
 > }
 > }

At what point is the Terminate() / your destructor getting invoked ? If the loop just does an handle alloc, it would obviously show an increase in memory.

Rgds.
Amogh Received on Wed Apr 26 2006 - 05:14:18 CDT

Original text of this message

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