Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Memory Leak Oracle 8.0
Hi,
I just finished my tests. So the result is - there is NO memory leak in OCI7 implementation of Oracle 8.0.3 client for NT and there IS a memory leak in OCI8 implementation of the same client. This is the reason why Server Manager works correctly (OCI7) but SQL Plus has memory leak (OCI8).
This OCI7 test source:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <oratypes.h> #include <ocidfn.h> #include <ociapr.h>
struct cda_def lda;
unsigned char hda[512];
int checkerr(struct cda_def *lda,int i);
int main(int argc,char **argv)
{
int i=0,j,k;
if(argc!=5)
printf("testcon7 <username> <password> <sqlnetalias> <iterations>\n");
else
{
k=atoi(argv[4]);
for(j=1;j<=k;j++)
{
memset(&lda,0,sizeof(lda));
memset(&hda,0,sizeof(hda));
if(i=checkerr(&lda,olog(&lda,hda,argv[1],-1,argv[2],-1,argv[3],-1,OCI_LM_DEF))) goto err1;
printf("Connect iteration %d\n",j);
if(i=checkerr(&lda,ologof(&lda))) goto err1;
}
}
err1: return i;
}
int checkerr(struct cda_def *lda,int i)
{
char errbuf[1024];
if(i)
{
oerhms(lda,(short)i,errbuf,sizeof(errbuf));
printf("Error %s",errbuf);
}
return i;
}
This is OCI8 test source:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <oci.h>
#define anderror(i,j) ((i)=(i)?(i):(j))
static OCIEnv *envhp;
static OCIError *errhp;
static OCIServer *srvhp;
static OCISvcCtx *svchp;
static OCISession *authp;
int checkerr(OCIError *errhp,int i);
int main(int argc,char **argv)
{
int i=0,e,j,k;
if(argc!=5)
printf("testcon7 <username> <password> <sqlnetalias> <iterations>\n");
else
{
if(i=OCIInitialize(OCI_DEFAULT,NULL,NULL,NULL,NULL)) goto err99; if(i=OCIEnvInit(&envhp,OCI_DEFAULT,0,NULL)) goto err99; if(i=OCIHandleAlloc(envhp,&errhp,OCI_HTYPE_ERROR,0,NULL)) goto err98; if(i=OCIHandleAlloc(envhp,&srvhp,OCI_HTYPE_SERVER,0,NULL)) goto err97; if(i=OCIHandleAlloc(envhp,&svchp,OCI_HTYPE_SVCCTX,0,NULL)) goto err96;k=atoi(argv[4]);
if(i=checkerr(errhp,OCIServerAttach(srvhp,errhp,argv[3],strlen(argv[3]),OCI_DEFAULT))) goto err95; if(i=checkerr(errhp,OCIAttrSet(svchp,OCI_HTYPE_SVCCTX,srvhp,0,OCI_ATTR_SERVER,errhp))) goto err94; if(i=OCIHandleAlloc(envhp,&authp,OCI_HTYPE_SESSION,0,NULL)) goto err94; if(i=checkerr(errhp,OCIAttrSet(authp,OCI_HTYPE_SESSION,argv[1],strlen(argv[1]),OCI_ATTR_USERNAME,errhp))) goto err93; if(i=checkerr(errhp,OCIAttrSet(authp,OCI_HTYPE_SESSION,argv[2],strlen(argv[2]),OCI_ATTR_PASSWORD,errhp))) goto err93; if(i=checkerr(errhp,OCISessionBegin(svchp,errhp,authp,OCI_CRED_RDBMS,OCI_DEFAULT))) goto err93; if(i=checkerr(errhp,OCIAttrSet(svchp,OCI_HTYPE_SVCCTX,authp,0,OCI_ATTR_SESSION,errhp))) goto err92;printf("Connect iteration %d\n",j);
err92: e=checkerr(errhp,OCISessionEnd(svchp,errhp,authp,OCI_DEFAULT)); anderror(i,e); err93: e=OCIHandleFree(authp,OCI_HTYPE_SESSION); anderror(i,e); err94: e=checkerr(errhp,OCIServerDetach(srvhp,errhp,OCI_DEFAULT)); anderror(i,e);if(i) goto err95;
err95: e=OCIHandleFree(svchp,OCI_HTYPE_SVCCTX); anderror(i,e); err96: e=OCIHandleFree(srvhp,OCI_HTYPE_SERVER); anderror(i,e); err97: e=OCIHandleFree(errhp,OCI_HTYPE_ERROR); anderror(i,e); err98: e=OCIHandleFree(envhp,OCI_HTYPE_ENV); anderror(i,e);}
You may try this with newer Oracle client software.
Andrew Protasov
> Hello!
>
>
>
>
>
>
>
>
>
>> >for NT during this test.
> >
> >Hi,
> >
> >I tried your test with Oracle Client and Server 8.0.3. Yes,
> >there is a memory leak in plus80.exe and plus80w.exe
> >(Windowed version). But I did not find any memory leak
> >with your test in svrmgr30.exe (Server Manager). Maybe
> >it depends on OCI version? I do not know what OCI 7 or
> >OCI 8 each of them uses.
> >
> >And there is no any memory leak in Oracle 8.0.3 Server
> > >Received on Fri Dec 11 1998 - 17:27:42 CST