Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Memory leaks on OCIEnvCreate ?
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.
>
You gave
::OCIHandleFree( m_pErr, OCI_HTYPE_ENV );
Should it be m_pEnv that should be freed in the above call?
-KM Received on Thu Apr 27 2006 - 04:26:42 CDT
![]() |
![]() |