Board index » delphi » Unloading bold objects.

Unloading bold objects.


2005-02-18 09:55:46 PM
delphi63
Hi,
I have a form that has a TBoldListBox. I select an object and then unload it
by calling boldObjectLocater.UnloadBoldObject on the instance. The object
has the association ObjectA (1) ------(0...*) ObjectB. I am calling
boldObjectLocater.UnloadBoldObject on each of instances of ObjectB in the
association when I unload ObjectA.
Now when I go back to the form and re-select the object, I get a
boldLinks.pas error.
How can I correctly unload the object without getting this error ?
Sham.
 
 

Re:Unloading bold objects.

Quote
How can I correctly unload the object without getting this error ?
Do you need to do it this way, or can you use the object unloader
component to unload objects not touched for X minutes instead?
--
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 bold objects.

"Peter Morris [Droopy eyes software]" <XXXX@XXXXX.COM>
writes news:42160e54$XXXX@XXXXX.COM...
Quote
>How can I correctly unload the object without getting this error ?

Do you need to do it this way, or can you use the object unloader
component to unload objects not touched for X minutes instead?
What's the difference between what it does and what we're doing?
We need to keep memory usage to a minimum as our clients have *very* basic
machines! The app is wizard based, so we know that an object is no longer
required when a wizard completes. This would seem like the logical place to
unload objects.
Bryan
 

Re:Unloading bold objects.

Quote
What's the difference between what it does and what we're doing?
I just wanted to make sure he knew about it, so that he didn't need to
do it manually. Sounds like manual is okay in your case though.
Have you first ensured that
A) BoldObject.BoldPersistent
B) not BoldObject.BoldDirty
C) not BoldObject.ObjectHasSubscribers
Quote
We need to keep memory usage to a minimum as our clients have *very* basic
machines! The app is wizard based, so we know that an object is no longer
required when a wizard completes. This would seem like the logical place to
unload objects.
You could set the unloader to scan every 60 seconds?
--
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 bold objects.

Hi Pete,
A and B are fine, however the object has some subscriptions. Is there a way
of removing the subscription in code?
Sham.
"Peter Morris [Droopy eyes software]" <XXXX@XXXXX.COM>
writes news:XXXX@XXXXX.COM...
Quote
>What's the difference between what it does and what we're doing?

I just wanted to make sure he knew about it, so that he didn't need to
do it manually. Sounds like manual is okay in your case though.

Have you first ensured that

A) BoldObject.BoldPersistent
B) not BoldObject.BoldDirty
C) not BoldObject.ObjectHasSubscribers


>We need to keep memory usage to a minimum as our clients have *very*
basic
>machines! The app is wizard based, so we know that an object is no
longer
>required when a wizard completes. This would seem like the logical
place to
>unload objects.

You could set the unloader to scan every 60 seconds?


--
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 bold objects.

Peter Morris [Droopy eyes software] writes:
Quote
Have you first ensured that

C) not BoldObject.ObjectHasSubscribers

Is it required to make sure there are no subscribers? can not you have
subscriptions on objects that aren't loaded?
In that case, what happens if A.AttrA is derived and subscribes to
B.AttrB, B is unloaded (and subscription removed), B is reloaded (for
other reasons), B.AttrB changes. How does A.AttrA get to know about the
change in B.AttrB?
Kjell
--
---------------------------------------------------------------------------
Kjell Rilbe
Home: +46 8 7610734
Cell: +46 733 442464
---------------------------------------------------------------------------
"If there's a price for bein' me, that is one I will have to pay"
Aaron Tippin
---------------------------------------------------------------------------
 

Re:Unloading bold objects.

Quote
A and B are fine, however the object has some subscriptions. Is there a way
of removing the subscription in code?
Not sure. Try something like this
type
TAccessBoldObject = class(TBoldObject);
....
TAccessBoldObject(MyObject).Publisher.NotifySubscribersAndClearSubscriptions(MyObject);
I don't know if that is the right thing to do, or even a clever thing to
do, but you could try it :-)
Maybe you should be looking at why you have subscribers instead?
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 bold objects.

Quote
In that case, what happens if A.AttrA is derived and subscribes to
B.AttrB, B is unloaded (and subscription removed), B is reloaded (for
other reasons), B.AttrB changes. How does A.AttrA get to know about the
change in B.AttrB?
To be honest I don't know how it works. I'd guess though that there
are stages
1) Nothing loaded
2) ObjectLocator loaded
3) ObjectLocator + Object loaded
4) ObjectLocator + Object loaded + data fetched
If you unload an object then the subscriptions to its attributes would
have to be cleared. Placing the subscriptions would (I imagine) at
least load the locator and maybe the object without and attributes fetched.
--
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 bold objects.

Peter Morris [Droopy eyes software] writes:
Quote
>In that case, what happens if A.AttrA is derived and subscribes to
>B.AttrB, B is unloaded (and subscription removed), B is reloaded (for
>other reasons), B.AttrB changes. How does A.AttrA get to know about
>the change in B.AttrB?

To be honest I don't know how it works. I'd guess though that there
are stages

1) Nothing loaded
2) ObjectLocator loaded
3) ObjectLocator + Object loaded
4) ObjectLocator + Object loaded + data fetched
This brings up additional questions. When you tell Bold to unload an
object, what does it actually unload? Which of the above four states is
the result after an unload?
Quote
If you unload an object then the subscriptions to its attributes would
have to be cleared. Placing the subscriptions would (I imagine) at
least load the locator and maybe the object without and attributes fetched.
But how is that relevant to my question? If the subscriptions are
cleared when the subscribed-to object is unloaded, what mechanisms are
there to resubscribe when the object is loaded again? If no such
mechanis exists, I fail to see how it could ever work to unload objects
that have subscribers.
I would actually have expected all of this to be solved internally. The
subscription mechanism is a rather high-level concept and shouldn't be
messed up by under-the-cover stuff like loading and unloading of objects.
Kjell
--
---------------------------------------------------------------------------
Kjell Rilbe
Home: +46 8 7610734
Cell: +46 733 442464
---------------------------------------------------------------------------
"If there's a price for bein' me, that is one I will have to pay"
Aaron Tippin
---------------------------------------------------------------------------
 

Re:Unloading bold objects.

Hi
This is all guess work :-)
Quote
This brings up additional questions. When you tell Bold to unload an
object, what does it actually unload? Which of the above four states is
the result after an unload?
I would say
2) ObjectLocator loaded
Quote
But how is that relevant to my question? If the subscriptions are
cleared when the subscribed-to object is unloaded, what mechanisms are
there to resubscribe when the object is loaded again? If no such
mechanis exists, I fail to see how it could ever work to unload objects
that have subscribers.
If you forcibly unload an object then that is your own doing, you
obviously want nothing more to do with it so existing subscriptions may
be cancelled. Bold "probably" also markes derived attributes as
invalid, so if you access them again the object will be reloaded.
This is why you should check that there are no subscriptions before
unloading.
Quote
I would actually have expected all of this to be solved internally. The
subscription mechanism is a rather high-level concept and shouldn't be
messed up by under-the-cover stuff like loading and unloading of objects.
If you use the unloader component instead of unloading manually,
everything is handled just fine.
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/