Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> OCI error handle is freed only with environment handle
While writing an application that keeps open connections to oracle database, I
ran into an interesting problem:
It seems as the error handle is not freed until its related environment handle
is freed,
although using OCIHandleFree with the error handle.
I have written a short OCI program to show it:
consider two functions:
1.
void select1(OCIEnv *envhp, OCISvcCtx *svchp) {
OCIStmt *stmthp; OCIError *errhp; (void) OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &errhp, OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) 0); checkerr(errhp, OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &stmthp,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));
checkerr(errhp, OCIStmtPrepare(stmthp, errhp, sel, (ub4) strlen((char *) sel), (ub4)
status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0,
(CONST OCISnapshot *)
NULL,
(OCISnapshot *) NULL,
2.
void select2(OCIEnv *envhp, OCISvcCtx *svchp, OCIError *errhp) {
OCIStmt *stmthp;
checkerr(errhp, OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &stmthp,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));
checkerr(errhp, OCIStmtPrepare(stmthp, errhp, sel, (ub4) strlen((char *) sel), (ub4)
status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0,
(CONST OCISnapshot *)
NULL,
(OCISnapshot *) NULL,
Assume all necessary handles are allocated and freed in the main function.
'checkerr' is checking errors.
When calling 'select1' in an endless loop - a memory leak occur.
When calling 'select2' in an endless loop - the memory leak does not occur.
Does anyone know the reason?
Thanks, Amit.
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Feb 03 1999 - 09:15:16 CST
![]() |
![]() |