http://qs321.pair.com?node_id=111195

Stegalex has asked for the wisdom of the Perl Monks concerning the following question:

I have had a persistent problem for a while with my httpd daemons consuming all my box's memory and CPU after a couple of hours. Now most people will say that this is normal, httpd sucks memory and you can't always believe what top says. However, site performance slows down and some programs die from memory starvation, so this is far from an OK thing.

After much research, I have pinpointed the problem to one lousy sql statement that sometimes inexplicably leaves a cursor opened in Oracle. When this happens, the httpd process it is running under bloats and starts sucking CPU and doesn't stop until I restart httpd.

I am certain that there is not a logic error in my code. The cursors are SPORADICALLY left open even though the cursor is closed unconditionally after it's no longer needed.

Before I go much further, here's the info about my setup.

Apache 1.3.12
Oracle: 8.1.5.0.2
Perl 5.6.0
RH Linux 7
DBI 1.14
mod_perl 1.24
html::embperl 1.3.1


Has anyone else encountered situations where doing an $sth->finish; doesn't work?

I know the cursors are being left open because I have examined the sql_text column in the v$open_cursors view in oracle and it shows me the statement that has the open cursor. When I kill the offending httpd process, the cursor gets closed.

Strange.