Board index » delphi » unloading objects

unloading objects


2005-02-28 03:31:38 PM
delphi102
does anyone use some kind of object unloading ?
I don't mean garbage collection .. but unloading an objects details
let's say you have a list of invoices .. it has a details property with
item infos (product, quantity, rebate, ..)
first you only load the invoice info (serial no., customer, total price,
date, ...)
then you'd like to edit/print it and you have to load the details as well
...
so far I have got it covered :)
but in time when you're not using/referencing these invoices (or other
documents), you don't need those details
when the app's running all day it loads a lot of those objects that are
not needed
this can eat up a lot of memory
so .. does anyone unload those unused objects ? I would just unload the
details .. the main info is still used
would a timed collect and unload be ok ?
 
 

Re:unloading objects

Quote
so .. does anyone unload those unused objects ?
Some people implement an object cache that does that sort of thing.
Cheers,
Jim Cooper
__________________________________________
Jim Cooper XXXX@XXXXX.COM
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
 

Re:unloading objects

Quote
>so .. does anyone unload those unused objects ?

Some people implement an object cache that does that sort of thing.
yea .. you not one of them ? why ? :-)
 

Re:unloading objects

"Lee_Nover" <Lee_Nover[nospam]@delphi-si.com>writes
does anyone use some kind of object unloading ?
Yes - Bold has the concept of an ObjectLocator object - very lightweight
object that stores the ID and a pointer to the object itself. You don't
store a pointer to the object, but to its locator. When you access
locator.object, the locator checks to see if the object is in memory and if
not it loads it.
This enables you to unload objects without breaking pointers.
Bryan
 

Re:unloading objects

"Lee_Nover" wrote
Quote
.. does anyone unload those unused objects ? I would just unload
the details .. the main info is still used
would a timed collect and unload be ok ?
Only if the usage pattern for the collection will be the same under all
usage scenarios and applications. You could of course make the timing
adjustable, but then you introduce configuration issues.
Why not just give the application developer the decision (by, for example,
adding a TInvoice.UnloadLineItemsCollection method)? That prevents you from
needing to guess in the framework the conditions under which this is a good
or bad idea.
If you do decide to go the timer route, then you might consider adding a
metronome service to your framework rather than embedding timing into the
collection. Interested objects subscribe to the timer, and do whatever they
want on the pulse, so it would work for unloading collections or any other
type of resource management you want to automate.
bobD
 

Re:unloading objects

Quote
Yes - Bold has the concept of an ObjectLocator object - very lightweight
object that stores the ID and a pointer to the object itself. You don't
store a pointer to the object, but to its locator. When you access
locator.object, the locator checks to see if the object is in memory and if
not it loads it.

This enables you to unload objects without breaking pointers.
yep .. did some BOLD stuff and loved it :)
sadly the boss is "affraid" of BOLD
I'll check the approach
 

Re:unloading objects

Quote
Why not just give the application developer the decision (by, for example,
adding a TInvoice.UnloadLineItemsCollection method)? That prevents you from
needing to guess in the framework the conditions under which this is a good
or bad idea.
I am the developer :) this unloading will be done on app base :)
Quote
If you do decide to go the timer route, then you might consider adding a
metronome service to your framework rather than embedding timing into the
collection. Interested objects subscribe to the timer, and do whatever they
want on the pulse, so it would work for unloading collections or any other
type of resource management you want to automate.
I was thinking of a similar route .. the object would implement an IUnloadable interface and add itself to an object managment list
"the list" would then simply call the Unload method
but I like the extra asking method better .. tnx ! :)
 

Re:unloading objects

"Lee_Nover" wrote
Quote
the object would implement an IUnloadable interface and
add itself to an object managment list "the list" would then
I like to be a bit more granular in separating out the how from the what: a
metronome is a generic service to which many things can subscribe for their
own purposes, whereas an unloader is a very specific object.
bobD
 

Re:unloading objects

Quote
sadly the boss is "affraid" of BOLD
Strange person.
Reading/writing an attribute probably updates some kind of internal
"DateLastAccessed" member in the object locator. The unloader component
then knows which objects haven't been used for X minutes and unloads them.
--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
www.droopyeyes.com
Read or write articles on just about anything
www.HowToDoThings.com
My blog
blogs.slcdug.org/petermorris/
 

Re:unloading objects

Quote
yea .. you not one of them ? why ? :-)
I've used OPF with a cache, but not written one. I started writing an
OPF with a cache, but the project didn't get off the ground :(
Cheers,
Jim Cooper
__________________________________________
Jim Cooper XXXX@XXXXX.COM
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________