/usr/share/doc/libdbd-odbc-perl/examples/leakcheck.pl is in libdbd-odbc-perl 1.52-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | #!/usr/bin/perl -w
# $Id$
use Devel::Leak;
use DBI qw(:sql_types);
use strict;
my $insert_value = 0;
my $long = "a" x 1000;
sub connecttest {
my $dbh = DBI->connect();
$dbh->disconnect;
}
sub preparetest {
my $dbh = DBI->connect();
$dbh->{LongReadLen} = 800;
my $sth=$dbh->prepare("select * from PERL_DBD_TEST");
my @row;
$sth->execute;
while (@row = $sth->fetchrow_array) {
}
}
sub inserttest ($) {
my $delete = shift;
my $dbh = DBI->connect();
$dbh->{LongReadLen} = 1500;
if ($delete) {
$dbh->do("delete from perl_dbd_test");
}
my $sth=$dbh->prepare("insert into PERL_DBD_TEST (COL_A, COL_C) values ($insert_value, ?)");
my @row;
$sth->bind_param(1, $long, SQL_LONGVARCHAR);
$sth->execute;
$insert_value++;
}
sub selecttest {
my $dbh = DBI->connect();
$dbh->{LongReadLen} = 1500;
my $sth=$dbh->prepare("select COL_A, COL_C FROM PERL_DBD_TEST order by col_a");
my @row;
$sth->execute;
while (@row = $sth->fetchrow_array) {
}
}
my $handle;
my $i =0;
my $count;
my $count2;
my $count3;
my $count4;
my $count5;
my $count6;
my $count7;
my $count8;
$count = Devel::Leak::NoteSV($handle);
$i = 0;
while ($i < 100) {
connecttest;
$i++;
}
$count2 = Devel::Leak::CheckSV($handle);
$count2 = Devel::Leak::NoteSV($handle);
preparetest;
$count3 = Devel::Leak::CheckSV($handle);
$count3 = Devel::Leak::NoteSV($handle);
$i = 0;
while ($i < 100) {
preparetest;
$i++;
}
$count4 = Devel::Leak::CheckSV($handle);
$count4 = Devel::Leak::NoteSV($handle);
inserttest(1);
$count5 = Devel::Leak::CheckSV($handle);
$count5 = Devel::Leak::NoteSV($handle);
$i = 0;
while ($i < 100) {
inserttest(0);
$i++;
}
$count6 = Devel::Leak::CheckSV($handle);
$count6 = Devel::Leak::NoteSV($handle);
selecttest;
$count7 = Devel::Leak::CheckSV($handle);
$count7 = Devel::Leak::NoteSV($handle);
$i = 0;
while ($i < 100) {
selecttest;
$i++;
}
$count8 = Devel::Leak::CheckSV($handle);
# $count8 = Devel::Leak::NoteSV($handle);
print "$count, $count2, $count3, $count4, $count5, $count6, $count7, $count8\n";
|