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: help!"EXEC SQL ENABLE THREADS" cause memory leak?

Re: help!"EXEC SQL ENABLE THREADS" cause memory leak?

From: Mladen Gogala <gogala_at_sbcglobal.net>
Date: Mon, 12 Dec 2005 06:10:06 GMT
Message-Id: <pan.2005.12.12.06.10.05.798639@sbcglobal.net>


On Sun, 11 Dec 2005 16:00:55 +0000, IANAL_VISTA wrote:

>> main()
>> {
>> ....
>> char array_a[64];
>> EXEC SQL END DECLARE SECTION;
>>
>> EXEC SQL ENABLE THREADS;
>> EXEC SQL CONNECT :loginuser IDENTIFIED BY :usrpwd USING :dbstr;
>> ......
>>
>> while(1)
>> {
>> EXEC SQL SELECT field_a INTO :array_a FROM table_a WHERE
>> field_b=122;
>> }
>>
>> }
>> /*********************************/

> 
> From my perspective, what you descibe is expected behavior.
> You've coded an infinite loop which populates a memory array.
> So of course the process RAM consumption will increase.

Your perspective is probably wrong. He is selecting a field into a string (array_a is string which can accommodate 64 characters) and he's repeatedly parsing the same SQL statement and selecting same string again and again, overwriting the previous value each time. In addition to that, his program works when threads are not enabled. The program doesn't make sense, it parses the same statement over and over again, but there is nothing wrong about it. There is probably a bug multiplying cursors or something like that when threads are enabled.

As a piece of advice, you don't really want threads enabled on the client side. If you do have a database job that needs to be broken into pieces, use fork() and exec(). They're far more reliable than OS threads.

-- 
http://www.mgogala.com
Received on Mon Dec 12 2005 - 00:10:06 CST

Original text of this message

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