To echo another recent poster with a DBI problem, "I'm just not seeing it!"

I am using Class::DBI to describe various tables and add new data records to them.   As I add 1000's of new records using  ->create()  the Perl program memory size grows proportionally to record count and average data size per record.   Memory is not released until end of program.

I'd thought that with the default Class::DBI setting of   AutoCommit=>1   I'd not need to worry about 'details' like records accumulating until I did an explicit commit.   I'm afraid something more subtle is wrong (with my understanding of course).   Example program is as follows:

use strict; use warnings; package MyTest1; use base 'Class::DBI'; __PACKAGE__->set_db('Main', 'dbi:mysql:test', undef, undef, { RaiseErr +or => 1 } ); __PACKAGE__->table('test1'); __PACKAGE__->columns( All => qw( id logtext ) ); package main; printf " db_Main is '%s'\n", MyTest1->db_Main; printf " AutoCommit is '%s'\n", MyTest1->db_Main->{AutoCommit}; printf " RaiseError is '%s'\n", MyTest1->db_Main->{RaiseError}; MyTest1->db_Main->do( 'DROP TABLE IF EXISTS test1' ); MyTest1->db_Main->do( <<EOSQL ); CREATE TABLE IF NOT EXISTS test1 ( id INTEGER NOT NULL, logtext VARCHAR(255) NOT NULL, PRIMARY KEY (id) ) EOSQL my $newentry; for( my $i=0 ; $i<10000 ; ++$i ) { $newentry = MyTest1->create( { id=>$i, logtext=>'faked' } ); unless( $newentry ) { printf "*Error: Unable to create new entry object\n"; last; } } my( $count ) = MyTest1->db_Main->selectrow_array( 'SELECT count(*) FROM test1' ); printf " Record count '%d'\n", $count; printf " db_Main is '%s'\n", MyTest1->db_Main; printf " AutoCommit is '%s'\n", MyTest1->db_Main->{AutoCommit};
Sanity check output is:
  db_Main is    'Ima::DBI::db=HASH(0x2343a38)'
  AutoCommit is '1'
  RaiseError is '1'
  Record count  '10000'
  db_Main is    'Ima::DBI::db=HASH(0x2343a38)'
  AutoCommit is '1'
I must be missing some pretty fundamental 'gotcha' in the interactions between Class::DBI methods, objects, data and such.   Uh, hep, hep!

Environment is WinXP, ActiveState 5.6.1 build 635, Class::DBI 0.94, DBD::mysql 2.9002, MySQL 3.23.52


In reply to Class::DBI and create: program memory just grows and grows by shenme

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.