Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: how to free memory in Pro*C

Re: how to free memory in Pro*C

From: Dave Hau <davehau-no-spam-123_at_no-spam.netscape.net>
Date: Sat, 08 Nov 2003 22:27:36 GMT
Message-ID: <s5erb.3202$p96.514@newssvr23.news.prodigy.com>


You can do the allocation and freeing of the runtime contexts within the main program, and pass the contexts to each thread, like in the example Oracle gave in the Pro*C doc:

http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a97269/pc_11thr.htm#998992

main()
{

   sql_context ctx1,ctx2; /* declare runtime contexts */    EXEC SQL ENABLE THREADS;
   EXEC SQL CONTEXT ALLOCATE :ctx1;
   EXEC SQL CONTEXT ALLOCATE :ctx2;
   ...
/* spawn thread, execute function1 (in the thread) passing ctx1 */

   thread_create(..., function1, ctx1);
/* spawn thread, execute function2 (in the thread) passing ctx2 */

   thread_create(..., function2, ctx2);
   ...
   EXEC SQL CONTEXT FREE :ctx1;
   EXEC SQL CONTEXT FREE :ctx2;
   ...
}

void function1(sql_context ctx)
{

   EXEC SQL CONTEXT USE :ctx;
/* execute executable SQL statements on runtime context ctx1!!! */

   ...
}

void function2(sql_context ctx)
{

   EXEC SQL CONTEXT USE :ctx;
/* execute executable SQL statements on runtime context ctx2!!! */

   ...
}

HTH,
Dave

"Moon~" <whmoon_at_kynax.com> wrote in message news:bod1mj$2tk$1_at_news1.kornet.net...
> Hi..
> I¡¯m coding some kind of multi-thread program in Oracle9i/Solaris by
Pro*C.
> The structure of that program is to alloc memory in thread but I don¡¯t
> think that the function of ¡®free()¡¯ works after termination of a thread.
> That is, unfortunately the increasing memory could have been stopped after
> free().
> In addition, when defining sql_context, ¡°EXEC SQL ENABLE THREADS;¡±
cannot
> help to free memory but the memory can be returned without ¡°EXEC SQL
ENABLE
> THREADS;¡±
>
> EXEC SQL ENABLE THREADS;
>
> EXEC SQL CONTEXT ALLOCATE :context_var;
>
> EXEC SQL CONTEXT USE :context_var;
>
> EXEC SQL CONTEXT FREE :context_var;
>
>
>
> Could you please tell me the way to solve this problem
>
>
>
>
>
Received on Sat Nov 08 2003 - 16:27:36 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US