hardburn has asked for the wisdom of the Perl Monks concerning the following question:

From the Class::DBI documentation:

Currently the iterator initially fetches all the matching row data into memory, and defers only the creation of the objects from that data until the iterator is asked for the next object. So using an iterator will only save significant memory if your objects will inflate substantially when used. (emphisis mine)

Can anybody give me an example of when this might happen? I can't think of a case where the object itself would cause significantly more memory to be used, and I imagine it doesn't come up a lot, but I could be wrong.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Class::DBI Iterator Memory Usage
by dragonchild (Archbishop) on Sep 12, 2003 at 18:27 UTC
    If you have a lot of delayed building of contained objects, for example. I worked in one place that deferred every single thing that could be deferred. It was nice, unless you needed to get something from the root node. It then build everything all at once. Talk about a smack in the face!

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: Class::DBI Iterator Memory Usage
by bsb (Priest) on Sep 13, 2003 at 07:46 UTC
    That comment doesn't refer to Perl objects in general.

    It's talking about the inflation that turns the raw database data into an object, mostly has_a relations. See the CDBI docs and code.

    Examples:

    You store the id field of another row in some other table and it inflates to another CDBI object representing that row. (Normal has_a)

    You have a Storable serialized object stored in a string column in the database. "inflate" deserializes it.