MySQL do() memory leak?
- From: "daviddamerell@xxxxxxxxxxxxxx" <daviddamerell@xxxxxxxxxxxxxx>
- Date: 29 Nov 2006 06:13:30 -0800
Hi all,
I am using DBD::mysql and I can't work out where a memory leak is
coming from, I have included the program below. The program eventually
eats it's way through all of the main memory and then the swap, any
ideas? I have tried replacing the do with an execute("insert into")
statement.
Versions:
DBD::mysql=3.0002
#!/usr/bin/perl -w
use strict;
use lib '.';
use ui;
use mysql;
use Error qw(:try);
#Redirect STDERR away from terminal
open(STDERR,">stderr.log") || die "Could not open stderr log file\n";
#Setup main window environment
my ($cui,$win);
#$cui=ui::setupCui();
#$win=ui::setupWin($cui);
#Setup information labels
#my $label=ui::createNewLabel($win,"Program to create a single MySQL
table from PDBSWS",5,1);
#my $status=ui::createNewLabel($win,"Status: Counting number of
entries",5,2);
#my $current=ui::createNewLabel($win,"-Entry-",5,4);
#my $error=ui::createNewLabel($win,"Error Message",5,15);
#Count the number of lines
#my $numLines=`wc -l /databases/pdbsws/pdbsws_res.txt`;
my $numLines=1000000;
#Create progress bar
#my $progressBar=ui::createNewProgressBar($win,$numLines,"Lines
read",5,6);
my $conn;
init();
#Count the number of lines
#my $numLines=`wc -l /databases/pdbsws/pdbsws_res.txt`;
#$status->text("Status: Number of lines $numLines");
#$status->draw();
#Storage variable for previously seen PDB Chain ID pairs
my $last="";
#my $preparedStatement=$conn->prepare("insert into pdbsws.main
(pdb,chain,uniprot_accession) values(?,?,?)");
my $i=1;
open(PDBSWS, '/databases/pdbsws/pdbsws_res.txt') || die "Could not open
file /databases/pdbsws/pdbsws_res.txt\n";
my @fields;
while(<PDBSWS>){ $fields[0]=undef; $fields[1]=undef; $fields[5]=undef;
#$progressBar->pos($i++);
#$progressBar->draw();
chomp();
@fields=split;
#if($fields[1]==undef){
# $fields[1]='@';
#}
if($fields[0]==undef){
#$error->text("Warning PDB code is undef!");
#$error->draw();
next;
}
#if($fields[5]==undef){
# $error->text("Warning Uniprot code is undef!");
# $error->draw();
# next;
#}
if($last ne "$fields[0]$fields[1]$fields[5]"){
$last="$fields[0]$fields[1]$fields[5]";
eval{
$conn->do("insert into pdbsws.main (pdb,chain,uniprot_accession)
values(?,?,?)", undef,$fields[0],$fields[1],$fields[5]);
#$preparedStatement->execute($fields[0],$fields[1],$fields[5]);
};if($@){
#$error->text($@);
#$error->draw();
}else{
#$current->text("Uploaded: $fields[0]$fields[1]$fields[5]");
#$current->draw();
}
}
}
sub init { my $mysql=shift();
$mysql = new mysql();
$mysql ->{'mysql::_user_name'} = 'david';
$mysql->{'mysql::_user_password'} = 'exahqq75';
$mysql->{'mysql::_db_name'} = 'mysql';
$mysql->{'mysql::_db_type'} = "mysql";
$mysql->{'mysql::_db_host'} = 'localhost';
$mysql->{'mysql::_new_line'} = "\n";
$mysql->{'mysql::database_type'} = "database";
$mysql->{'mysql::database_type'} = "database";
$mysql->search_databases();
$conn=$mysql->{'mysql::_db_handler'};
try{
$mysql->add_database("pdbsws");
}catch Error with{ my $ex=shift();
#$error->text($ex->text());
#$error->draw();
#sleep(5);
};
my $preparedStatement=$conn->prepare("create table pdbsws.main
(uniprot_accession varchar(6), pdb varchar(4), chain varchar(1),
primary key(uniprot_accession, pdb, chain) )");
eval{
$preparedStatement->execute();
};if($@){
#$error->text($@);
#$error->draw();
#sleep(5);
}
}
.
- Prev by Date: Connecting to more than one oracle database
- Next by Date: RE: Connecting to more than one oracle database
- Previous by thread: Connecting to more than one oracle database
- Next by thread: Can't get DBD:Oracle to work
- Index(es):