MorphicToolBuilder holds onto stuff...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

MorphicToolBuilder holds onto stuff...

Eliot Miranda-2
Hi All,

    if one looks at UIManager default toolBuilder one sees the widgets dictionary inside the tool builder can hold onto garbage.  It would be nice if the widgets were cleaned out when ToolBuilder is done opening.  Where's the right point to do this?

--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: MorphicToolBuilder holds onto stuff...

David T. Lewis
On Wed, Mar 18, 2015 at 03:58:13PM -0700, Eliot Miranda wrote:
> Hi All,
>
>     if one looks at UIManager default toolBuilder one sees the widgets
> dictionary inside the tool builder can hold onto garbage.  It would be nice
> if the widgets were cleaned out when ToolBuilder is done opening.  Where's
> the right point to do this?

At first glance, I'm inclined to think that the garbage collector should
do it.

The current Project has a UIManager, and that UIManager has a ToolBuilder.
But I don't see an obvious reason why a UIManager needs to have a dedicated
instance of ToolBuilder, as opposed to creating new instances as needed.

Maybe there is some reason that it needs to be set up this way, but my
first inclination would be to see if we can get rid of the toolBuilder
instance variable in UIManager, after which the garbage in the widget
registry would take care of itself.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: MorphicToolBuilder holds onto stuff...

marcel.taeumel (old)
Right, there is no need for a UIManager to hold an instance of a tool builder. In particular, the following code is sufficient to build a tool with the morphic tool builder:

ObjectExplorer new buildWith: MorphicToolBuilder new.

The builder is shared along the control flow of #buildWith: in any standard tool. There is no real speedup achieved by saving the instance of a builder for later use. I am not aware of any code that relies on it anyway.

We should do this:

- remove #toolBuilder and instance variable from UIManager
- change ToolBuilder >> #default to always create a new instance
- remove #default: from ToolBuilder

Then GC might work. :)

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: MorphicToolBuilder holds onto stuff...

marcel.taeumel (old)
I just did a quick benchmark:

| model |
model := ObjectExplorer new.
[(ToolBuilder open: model) delete] bench.

And could not measure any difference for both implementations. Seems that opening and closing windows is much more resource intensive than creating and initializing the GUI structures.

Even worse: My mental model for a tool builder actually was that it is *empty* when working with it in #buildWith: code.

Best,
Marcel