On Thu, 23 Nov 2006, John Siracusa wrote:
> > BTW, are these DB connections closed?
>
> That's what I meant when I wrote this:
>
> >> (In all of the above code, you should think about the eventual destruction
> >> of those global objects.)
Yeah, I noticed, though, that this code:
use Rose::DB::Object::Loader;
my $loader =
Rose::DB::Object::Loader->new(
db_dsn => 'dbi:mysql:dbname=testdb2',
db_username => 'root',
db_options => { AutoCommit => 1, ChopBlanks => 1, RaiseError => 1 },
class_prefix => 'My',
);
$loader->make_classes();
for (1..100000000) {
my $p = My::Product->new(name => "doesntexist");
$p->load(speculative => 1);
undef $p;
}
eats about 3mb of memory per sec. Anything else that needs to be done
to clean up?
-- Mike
Mike Schilli
[EMAIL PROTECTED]
>
> In the default case, with each object getting its own db, the database
> connections are closed when the Rose::DB objects go out of scope (which
> usually happens when their parent objects go out of scope). Example:
>
> if(...)
> {
> my $p = My::Product->new(id => 123);
> $p->load; # New db object created with new $dbh
> ...do stuff with $p...
> }
>
> # $p goes out of scope here, and so does $p's db (assuming it wasn't
> # shared with any other objects in the block above)
>
> When in doubt, you can turn on DBI->trace() to see when your DBI $dbh
> handles are being created and destroyed.
>
> -John
>
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Rose-db-object mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rose-db-object
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object