Path: dp-news.maxwell.syr.edu!spool.maxwell.syr.edu!drn.maxwell.syr.edu!news.maxwell.syr.edu!newscon02.news.prodigy.com!prodigy.net!newsmst01b.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr24.news.prodigy.net.POSTED!a25fe021!not-for-mail
From: Mladen Gogala <gogala@sbcglobal.net>
Subject: Re: help!"EXEC SQL ENABLE THREADS" cause memory leak?
User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table)
Message-Id: <pan.2005.12.12.06.10.05.798639@sbcglobal.net>
Newsgroups: comp.databases.oracle.server
References: <dnh7du$e15$1@news.yaako.com> <Xns972951ACF68F9SunnySD@70.168.83.30>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 43
NNTP-Posting-Host: 69.177.239.49
X-Complaints-To: abuse@prodigy.net
X-Trace: newssvr24.news.prodigy.net 1134367806 ST000 69.177.239.49 (Mon, 12 Dec 2005 01:10:06 EST)
NNTP-Posting-Date: Mon, 12 Dec 2005 01:10:06 EST
Organization: SBC http://yahoo.sbc.com
X-UserInfo1: SCSYQN_@OXWMRULYBJKD]_\@VR]^@B@MCPWZKB]MPXHBTWICYFWUQBKZQLYJX\_ITFD_KFVLUN[DOM_A_NSYNWPFWNS[XV\I]PZ@BQ[@CDQDPCL^FKCBIPC@KLGEZEFNMDYMKHRL_YYYGDSSODXYN@[\BK[LVTWI@AXGQCOA_SAH@TPD^\AL\RLGRFWEARBM
Date: Mon, 12 Dec 2005 06:10:06 GMT
Xref: dp-news.maxwell.syr.edu comp.databases.oracle.server:257534

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

