dbTalk Databases Forums  

Memory leaks on OCIEnvCreate ?

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Memory leaks on OCIEnvCreate ? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Herode
 
Posts: n/a

Default Memory leaks on OCIEnvCreate ? - 04-26-2006 , 04:40 AM






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.


Reply With Quote
  #2  
Old   
Amogh
 
Posts: n/a

Default Re: Memory leaks on OCIEnvCreate ? - 04-26-2006 , 05:14 AM






Herode wrote:
Quote:
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


Reply With Quote
  #3  
Old   
Herode
 
Posts: n/a

Default Re: Memory leaks on OCIEnvCreate ? - 04-26-2006 , 05:36 AM



A new object is allocated and destroyed in each loop. There are as many
call to Initialize() than to Terminate().

Anyway, I also tried with an explicit call to env.Terminate() in the
loop. With no better results...


Reply With Quote
  #4  
Old   
KM
 
Posts: n/a

Default Re: Memory leaks on OCIEnvCreate ? - 04-27-2006 , 04:26 AM





Herode wrote:
Quote:
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.

You gave
::OCIHandleFree( m_pErr, OCI_HTYPE_ENV );
Should it be m_pEnv that should be freed in the above call?

-KM



Reply With Quote
  #5  
Old   
Herode
 
Posts: n/a

Default Re: Memory leaks on OCIEnvCreate ? - 05-02-2006 , 03:35 AM



You're right. Shame on me... \
Thanks !


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.