After using more connections, the memory is not reclaimed. Tried using pure DBIish and it works well.
Here is an example script using the two approaches
#!/usr/bin/env raku
use DBIish;
use DBIish::Pool;
use Telemetry;
my $driver = 'mysql';
my $database = 'database';
my $user = 'someuser';
my $password = '1234';
# PURE DBIish
sub connect {
DBIish.connect( $driver, :$database, :$user, :$password, :RaiseError );
}
sub disconnect( $conn ) {
$conn.dispose();
}
for ^20000 {
my $conn = connect();
$conn.execute("SELECT 1");
if $_ %% 100 {
my $mem = T<max-rss> / 1024;
$mem.=round(0.01);
say $_ ~ " $mem";
sleep 0.005;
}
$conn.dispose();
}
# DBIish::Pool
my %connection-parameters = :$database, :$user, :$password;
my $pool = DBIish::Pool.new(:$driver, initial-size => 5, max-connections => 10, min-spare-connections => 1, max-idle-duration => Duration.new(60), |%connection-parameters);
for ^20000 {
my $dbh = $pool.get-connection();
$dbh.execute('SELECT 1');
if $_ %% 100 {
my $mem = T<max-rss> / 1024;
$mem.=round(0.01);
say $_ ~ " $mem =";
sleep 0.005;
}
$dbh.dispose;
}
say "END";
After using more connections, the memory is not reclaimed. Tried using pure DBIish and it works well.
Here is an example script using the two approaches