Home » Developer & Programmer » Precompilers, OCI & OCCI » Memory leaks in OCIEnvCreate() ?
Memory leaks in OCIEnvCreate() ? [message #169325] Wed, 26 April 2006 05:04 Go to next message
Herode
Messages: 12
Registered: February 2006
Location: Isère (France, 38)
Junior Member
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.

[Updated on: Wed, 26 April 2006 05:05]

Report message to a moderator

Re: Memory leaks in OCIEnvCreate() ? [message #174002 is a reply to message #169325] Thu, 25 May 2006 08:51 Go to previous message
rgruszka
Messages: 1
Registered: May 2006
Location: Poland
Junior Member
Hi,
I encountered similar problem.
When I compile one of the demos ($ORACLE_HOME/rdbms/demo/) and execute it with valgrind I get an information, saying that there are thousands of invalid reads and a memory leak. All works fine, I connect to server, execute sql statements, but the leak is there.

I run it on linux/gentoo, server v. 9.2.0.1.0, client 10.2.0.1.
Is this normal?


Here's the valgrind's output:
==10681== Memcheck, a memory error detector for x86-linux.
==10681== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==10681== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==10681== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==10681== For more details, rerun with: -v
==10681==
occidml - Exhibiting simple insert, delete & update operations
==10681== Conditional jump or move depends on uninitialised value(s)
==10681== at 0x1C4E3FC9: (within /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1C4E41B4: slpmloc (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1C4E1B83: lpmloadpkg (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1C4CB08C: (within /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1C4CAD92: (within /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1C4CA390: lfvini1 (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1C4CA108: lfvinit (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1C2B2B87: kpummpin (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1BBBDC3D: kpuenvcr (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1BC897E5: OCIEnvCreate (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1B95DD46: oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned), void* (*)(void*, void*, unsigned), void (*)(void*, void*)) (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libocci.so.10.1)
==10681== by 0x8049A91: occidml::occidml(std::string, std::string, std::string) (occidml.cpp:33)
==10681==
==10681== Syscall param times(buf) points to unaddressable byte(s)
==10681== at 0x1C878872: times (in /lib/tls/libc-2.3.6.so)
==10681== by 0x1BFB77CE: kghinp (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1BBBE687: kpuinit0 (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1BBBDC99: kpuenvcr (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1BC897E5: OCIEnvCreate (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libclntsh.so.10.1)
==10681== by 0x1B95DD46: oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned), void* (*)(void*, void*, unsigned), void (*)(void*, void*)) (in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libocci.so.10.1)
==10681== by 0x8049A91: occidml::occidml(std::string, std::string, std::string) (occidml.cpp:33)
==10681== by 0x804972D: main (occidml.cpp:248)
==10681== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==10681==
==10681== More than 30000 total errors detected. I'm not reporting any more.
==10681== Final error counts will be inaccurate. Go fix your program!
==10681== Rerun with --error-limit=no to disable this cutoff. Note
==10681== that errors may occur in your program without prior warning from
==10681== Valgrind, because errors are no longer being displayed.
==10681== ERROR SUMMARY: 30000 errors from 2 contexts (suppressed: 32 from 2)
==10681== malloc/free: in use at exit: 599248 bytes in 120 blocks.
==10681== malloc/free: 258 allocs, 139 frees, 606684 bytes allocated.
==10681== For counts of detected errors, rerun with: -v
==10681== searching for pointers to 120 not-freed blocks.
==10681== checked 1795264 bytes.
==10681==
==10681== LEAK SUMMARY:
==10681== definitely lost: 0 bytes in 0 blocks.
==10681== possibly lost: 1280 bytes in 1 blocks.
==10681== still reachable: 597968 bytes in 119 blocks.
==10681== suppressed: 0 bytes in 0 blocks.
==10681== Reachable blocks (those to which a pointer was found) are not shown.
==10681== To see them, rerun with: --show-reachable=yes

Previous Topic: Undefined Symbol Substr
Next Topic: Question : [ORA-12560 TNS:protocol adapter error]
Goto Forum:
  


Current Time: Thu Nov 21 10:05:49 CST 2024