| [reply] |
You should try to avoid opening and closing connections any more than necessary.
This is good advice, regardless of whether there's a memory leak or not. Opening and closing connections can be very time-consuming, particularly if the database is remote.
| [reply] |
loop and the database handle is destroyed at the end of the loop
Not really they are still saved in perl's memory for future use.. Perl does not really garbage collect -- you will see that any var that is assigned and then set to undef will actuall stay resident even after its undefed -- perl will then use that same memory when it can for future vars.
-Waswas | [reply] |
Are you using transactions? If so, it might be saving all the data in memory until you tell it to commit. Depends largely on how transactions are implemented on the underlieing database and DBD module.
---- I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
| [reply] |
If s?he's issuing a $dbh->disconnect; at the end of the say.. subroutine that does the inserts, it should commit the transactions. Issuing a $dbh->finish; (or was it $sth->finish; ?) before the disconnect may commit the records.
I currently use DBD::Sybase within mod_perl apps, but most of the time they are selecting rows from rather large tables vs inserting rows.
Have you tried some sort of BCP solution?
Just some thoughts..
One4k4 - perlmonks@poorheart.com (www.poorheart.com)
| [reply] [d/l] [select] |
If s?he's issuing a $dbh->disconnect; at the end of the say.. subroutine that does the inserts, it should commit the transactions. Issuing a $dbh->finish; (or was it $sth->finish; ?) before the disconnect may commit the records.
It's $sth->finish;.
Commiting the transaction wouldn't free the memory to the OS. It would go back into a pool that perl can use later. Fortunatly, on any OS with a sane VM implementation, the pages for that storage space would be swaped to the hard disk until perl needs to use them again.
---- I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
| [reply] [d/l] |