Note that there are some explanatory texts on larger screens.

plurals
  1. POmemory leak in *ProC file
    text
    copied!<p>I have some memory leak in my file and valgrind points to the code given below in the .cc file</p> <pre><code>sqlcxt(&amp;ctx, &amp;sqlctx, &amp;sqlstm, &amp;sqlfpn); </code></pre> <p>The code doesnot have this directly.The code is</p> <pre><code> SQLDA *bind_dp; SQLDA *select_dp; /* Allocate memory for the select and bind descriptors. */ if (!Db::alloc_descriptors(MAX_ITEMS, MAX_VNAME_LEN, MAX_INAME_LEN, bind_dp, select_dp)) goto errexit; EXEC SQL WHENEVER SQLERROR GOTO errexit_select; EXEC SQL PREPARE S FROM :query; EXEC SQL DECLARE C CURSOR FOR S; Db::set_bind_variables(bind_dp, &amp;paramList); EXEC SQL OPEN C USING DESCRIPTOR bind_dp; Db::process_select_list(select_dp, dbQueryRsp); /* When done, free the memory allocated for pointers in the bind and select descriptors. */ for (int i = 0; i &lt; MAX_ITEMS; i++) { if (bind_dp-&gt;V[i] != (char *) 0) free(bind_dp-&gt;V[i]); free(bind_dp-&gt;I[i]); /* MAX_ITEMS were allocated. */ if (select_dp-&gt;V[i] != (char *) 0) free(select_dp-&gt;V[i]); free(select_dp-&gt;I[i]); /* MAX_ITEMS were allocated. */ } /* Free space used by the descriptors themselves. */ SQLSQLDAFree( ctx, bind_dp); SQLSQLDAFree( ctx, select_dp); EXEC SQL WHENEVER SQLERROR CONTINUE; /* Close the cursor. */ EXEC SQL CLOSE C; </code></pre> <p>The alloc_descriptors is as follows:</p> <pre><code>bool Db::alloc_descriptors(int size, int max_vname_len, int max_iname_len, SQLDA *&amp;bind_dp, SQLDA *&amp;select_dp) { GET_CONTEXT_DEFINE_SQLCA; EXEC SQL CONTEXT USE :ctx; if ((bind_dp = SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { logMsg(DEBUG, 2,"Cannot allocate memory for bind descriptor."); return false; /* Have to exit in this case. */ } if ((select_dp = SQLSQLDAAlloc (ctx, size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { logMsg(DEBUG, 2,"Cannot allocate memory for select descriptor."); return false; } select_dp-&gt;N = MAX_ITEMS; /* Allocate the pointers to the indicator variables, and the actual data. */ for (int i = 0; i &lt; MAX_ITEMS; i++) { bind_dp-&gt;I[i] = (short *) malloc(sizeof (short)); select_dp-&gt;I[i] = (short *) malloc(sizeof(short)); bind_dp-&gt;V[i] = (char *) malloc(1); select_dp-&gt;V[i] = (char *) malloc(1); } return true; } </code></pre> <p>The total code i can give in the .cc file is</p> <pre><code> /* EXEC SQL OPEN C USING DESCRIPTOR bind_dp; */ { struct sqlexd sqlstm; sqlstm.sqlvsn = 12; sqlstm.arrsiz = 1; sqlstm.sqladtp = &amp;sqladt; sqlstm.sqltdsp = &amp;sqltds; sqlstm.stmt = ""; sqlstm.iters = (unsigned int )1; sqlstm.offset = (unsigned int )24; sqlstm.selerr = (unsigned short)100; sqlstm.cud = sqlcud0; sqlstm.sqlest = (unsigned char *)&amp;sqlca; sqlstm.sqlety = (unsigned short)4352; sqlstm.occurs = (unsigned int )0; sqlstm.sqcmod = (unsigned int )0; sqlstm.sqhstv[0] = (unsigned char *)bind_dp; sqlstm.sqhstl[0] = (unsigned long )0; sqlstm.sqhsts[0] = ( int )0; sqlstm.sqindv[0] = ( short *)0; sqlstm.sqinds[0] = ( int )0; sqlstm.sqharm[0] = (unsigned long )0; sqlstm.sqadto[0] = (unsigned short )0; sqlstm.sqtdso[0] = (unsigned short )0; sqlstm.sqphsv = sqlstm.sqhstv; sqlstm.sqphsl = sqlstm.sqhstl; sqlstm.sqphss = sqlstm.sqhsts; sqlstm.sqpind = sqlstm.sqindv; sqlstm.sqpins = sqlstm.sqinds; sqlstm.sqparm = sqlstm.sqharm; sqlstm.sqparc = sqlstm.sqharc; sqlstm.sqpadto = sqlstm.sqadto; sqlstm.sqptdso = sqlstm.sqtdso; sqlcxt(&amp;ctx, &amp;sqlctx, &amp;sqlstm, &amp;sqlfpn); } DbT::process_select_list(select_dp, dbQueryRsp); </code></pre> <p>can some one explain what does this mean.</p> <p>The dump of valgrind is this:</p> <pre><code>==1212== 124 bytes in 1 blocks are possibly lost in loss record 2,103 of 3,407 ==1212== at 0x4A078B8: malloc (vg_replace_malloc.c:270) ==1212== by 0x643CC59: sqlalc (in /home/product/11.2.0/client_1/lib/libclntsh.so.11.1) ==1212== by 0x7D32749: sqlbrl (in /home/product/11.2.0/client_1/lib/libclntsh.so.11.1) ==1212== by 0x6D96B7A: sqlbds (in /home/product/11.2.0/client_1/lib/libclntsh.so.11.1) ==1212== by 0x7D34543: sqlnst (in /home/product/11.2.0/client_1/lib/libclntsh.so.11.1) ==1212== by 0x7D3068A: sqlcxt (in /home/product/11.2.0/client_1/lib/libclntsh.so.11.1) ==1212== by 0x9440C25: execute(std::string const&amp;, cil_cch_namespace::ParamTypeListList const&amp;, cil_cch_namespace::QueryType&amp;, long&amp;, long&amp;, ExtError&amp;) (Db.cc:608) ==1212== by 0x94430B0: execute(std::string const&amp;, std::string&amp;, long&amp;, ExtError&amp;) (Db.cc:474) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload