SystemWindow instances can't be garbage-collected

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

SystemWindow instances can't be garbage-collected

Max Leske
First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

Sorry about that. Here’s my original question as posted on IRC:

Hi guys.
I have a couple of SystemWindow instances sitting around in my image which can’t be garbage collected. They all once showed a debugger but that debugger seems to be only referenced by the window.
I’m kind of running in circles. Does anyone have an idea how to find the root pointers which prevent garbage collection of an object? Using PointerFinder manually isn’t helping much (I’m in a Pharo 1.1.1 image).

Cheers,
Max
Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

kilon.alios
First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  

sorry can't help you with your question :(


On Sat, Jun 21, 2014 at 6:24 PM, Max Leske <[hidden email]> wrote:
First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

Sorry about that. Here’s my original question as posted on IRC:

Hi guys.
I have a couple of SystemWindow instances sitting around in my image which can’t be garbage collected. They all once showed a debugger but that debugger seems to be only referenced by the window.
I’m kind of running in circles. Does anyone have an idea how to find the root pointers which prevent garbage collection of an object? Using PointerFinder manually isn’t helping much (I’m in a Pharo 1.1.1 image).

Cheers,
Max

Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Sven Van Caekenberghe-2
In reply to this post by Max Leske
I guess you tried World Menu > Windows > Close all debuggers ?

Did you check the Process Browser ?

On 21 Jun 2014, at 17:24, Max Leske <[hidden email]> wrote:

> First off:
> <rant>why do we have an IRC channel if nobody seems to be listening??</rant>
>
> Sorry about that. Here’s my original question as posted on IRC:
>
> Hi guys.
> I have a couple of SystemWindow instances sitting around in my image which can’t be garbage collected. They all once showed a debugger but that debugger seems to be only referenced by the window.
> I’m kind of running in circles. Does anyone have an idea how to find the root pointers which prevent garbage collection of an object? Using PointerFinder manually isn’t helping much (I’m in a Pharo 1.1.1 image).
>
> Cheers,
> Max


Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Max Leske
In reply to this post by kilon.alios

On 21.06.2014, at 17:36, kilon alios <[hidden email]> wrote:

First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  

Probably true. We should consider closing it. We’ve had people there asking questions before. Some of them didn’t get an answer at all (bad image for us) or were pointed to the mailing list which they probably would have tried anyway if the channel hadn’t existed...


sorry can't help you with your question :(

Thanks anyway :)



On Sat, Jun 21, 2014 at 6:24 PM, Max Leske <[hidden email]> wrote:
First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

Sorry about that. Here’s my original question as posted on IRC:

Hi guys.
I have a couple of SystemWindow instances sitting around in my image which can’t be garbage collected. They all once showed a debugger but that debugger seems to be only referenced by the window.
I’m kind of running in circles. Does anyone have an idea how to find the root pointers which prevent garbage collection of an object? Using PointerFinder manually isn’t helping much (I’m in a Pharo 1.1.1 image).

Cheers,
Max


Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Max Leske
In reply to this post by Sven Van Caekenberghe-2

On 21.06.2014, at 17:39, Sven Van Caekenberghe <[hidden email]> wrote:

> I guess you tried World Menu > Windows > Close all debuggers ?

That will indeed close all windows but the instances still stick around.

>
> Did you check the Process Browser ?

Yes. I also killed everything Seaside related (no more entrypoints, processes, sessions…)

>
> On 21 Jun 2014, at 17:24, Max Leske <[hidden email]> wrote:
>
>> First off:
>> <rant>why do we have an IRC channel if nobody seems to be listening??</rant>
>>
>> Sorry about that. Here’s my original question as posted on IRC:
>>
>> Hi guys.
>> I have a couple of SystemWindow instances sitting around in my image which can’t be garbage collected. They all once showed a debugger but that debugger seems to be only referenced by the window.
>> I’m kind of running in circles. Does anyone have an idea how to find the root pointers which prevent garbage collection of an object? Using PointerFinder manually isn’t helping much (I’m in a Pharo 1.1.1 image).
>>
>> Cheers,
>> Max
>
>


Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

kilon.alios
In reply to this post by Max Leske
I don't know how familiar you are with irc channels , but that is pretty much standard behaviour. So no its definitely not a reason to close channel. I rather help people who keep trying to learn pharo than people who give up too easily to be frank with you. Quantity is not Quality ;) 


On Sat, Jun 21, 2014 at 6:41 PM, Max Leske <[hidden email]> wrote:

On 21.06.2014, at 17:36, kilon alios <[hidden email]> wrote:

First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  

Probably true. We should consider closing it. We’ve had people there asking questions before. Some of them didn’t get an answer at all (bad image for us) or were pointed to the mailing list which they probably would have tried anyway if the channel hadn’t existed...


sorry can't help you with your question :(

Thanks anyway :)



On Sat, Jun 21, 2014 at 6:24 PM, Max Leske <[hidden email]> wrote:
First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

Sorry about that. Here’s my original question as posted on IRC:

Hi guys.
I have a couple of SystemWindow instances sitting around in my image which can’t be garbage collected. They all once showed a debugger but that debugger seems to be only referenced by the window.
I’m kind of running in circles. Does anyone have an idea how to find the root pointers which prevent garbage collection of an object? Using PointerFinder manually isn’t helping much (I’m in a Pharo 1.1.1 image).

Cheers,
Max



Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Marcus Denker-4
In reply to this post by kilon.alios

On 21 Jun 2014, at 17:36, kilon alios <[hidden email]> wrote:

First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  


I am IRC when at work (and not forgetting to start the IRC client). But often when people ask questions it is exactly the wrong moment in time.
I just *can’t*  instantly drop what I am doing an tend to the IRC channel… I really wonder how people do it… do they really stop their work right in the
miiddle to answer questions? How are they productive? 

Marcus

Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Max Leske

On 21.06.2014, at 18:53, Marcus Denker <[hidden email]> wrote:


On 21 Jun 2014, at 17:36, kilon alios <[hidden email]> wrote:

First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  


I am IRC when at work (and not forgetting to start the IRC client). But often when people ask questions it is exactly the wrong moment in time.
I just *can’t*  instantly drop what I am doing an tend to the IRC channel… I really wonder how people do it… do they really stop their work right in the
miiddle to answer questions? How are they productive? 

I fully agree. I was just momentarily pissed off :)


Marcus


Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Max Leske
Found the problem, documenting it here in case anybody else ever needs this (remember, this is 1.1.1).

Open a debugger (e.g. by evaluating 1/0), then click into the lower right workspace and type something. OCompletion will now have added an entry to the EventManager actionMap with a ContextVariablesInspector instance as the key. There seems to be a cycle there that can’t be resolved by the garbage collector, since I wasn’t able to find any non weak global pointers (an OContext is referenced by an MessageSend in the action map. The OContext references a morph which is connected to the SystemWindow. Some of those morphs reference the ContextVariablesInspector as their model).
Anyhow, it should be safe to send EventManager>>cleanUp: with argument true (actionMaps and their contents get recreated on demand), which will release those entries and allow the garbage collector to collect the SystemWindows, other morphs and the Debugger instances.

Note that this is probably not an issue in later versions (e.g. 3.0 doesn’t include EventManager anymore) but it might be relevant for later 1.x versions.

Max


On 21.06.2014, at 20:44, Max Leske <[hidden email]> wrote:


On 21.06.2014, at 18:53, Marcus Denker <[hidden email]> wrote:


On 21 Jun 2014, at 17:36, kilon alios <[hidden email]> wrote:

First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  


I am IRC when at work (and not forgetting to start the IRC client). But often when people ask questions it is exactly the wrong moment in time.
I just *can’t*  instantly drop what I am doing an tend to the IRC channel… I really wonder how people do it… do they really stop their work right in the
miiddle to answer questions? How are they productive? 

I fully agree. I was just momentarily pissed off :)


Marcus



Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Max Leske
For documentation purposes, this is what I found to be necessary to really clean all window instances. Note that this only works reliably when invoked from a non-UI process (e.g. via WAKom).


cleanupWindows
"in general: the gabage collector seems to be unable to resolve all circular dependencies with weak pointers.
This forces us to explicitly remove the weak pointers to enable garbage colltection.
It also seems to be a problem to invoke the cleanup from within a UI process (e.g. from a workspace). 
Ergo: 
- when invoked from a workspace not all instances may be garbage collected
- when invoked from a non UI process (e.g. WAKom) all instances should have been collected
- performning a manual garbage collection after having invoked this code from a workspace will
(usually) remove the pending instances (new process context)"
| count |
count := 1.
self
cleanupEvents;
cleanupWorkspaces;
cleanupSystemWindows.
[ Smalltalk garbageCollect. count := count + 1 ] doWhileFalse: [
SystemWindow allSubInstances isEmpty or: [ count > 5 "arbitrary number" ] ]

cleanupWorkspaces
PluggableTextMorph allSubInstances do: [ :each | each  
hasUnacceptedEdits: false;
askBeforeDiscardingEdits: false;
myDependents: nil ]

cleanupSystemWindows
[ [ SystemWindow allSubInstances do: [ :window |
window 
makeClosable;
delete ] ] 
on: Error 
do: [ :ex | 
"may get here because we're trying to delete a window which has been deleted already."
ex return  ].
Smalltalk garbageCollect.
"already deleted but still hanging aroung (also see #cleanupEvents and #cleanupWorkspaces)"
SystemWindow allSubInstances 
select: [ :e | e model isNil and: [ e owner isNil ] ]
thenDo: [ :e |
"clean some known places where references can prevent GC"
UITheme current focusIndicator: nil.
ActiveHand mouseOverHandler initialize.
ActiveHand keyboardFocus: nil.
World cleanseStepList.
"e.g. Workspace has a dependents array wich can point to the window"
(PointerFinder pointersTo: e) do: [ :p | 
p class = DependentsArray ifTrue: [
"the first pointer is the 'main' pointer in about 99% of the cases"
(PointerFinder pointersTo: p) first removeDependent: e ] ] ] 
] on: Error do: [ "ignore” ]


On 21.06.2014, at 23:11, Max Leske <[hidden email]> wrote:

Found the problem, documenting it here in case anybody else ever needs this (remember, this is 1.1.1).

Open a debugger (e.g. by evaluating 1/0), then click into the lower right workspace and type something. OCompletion will now have added an entry to the EventManager actionMap with a ContextVariablesInspector instance as the key. There seems to be a cycle there that can’t be resolved by the garbage collector, since I wasn’t able to find any non weak global pointers (an OContext is referenced by an MessageSend in the action map. The OContext references a morph which is connected to the SystemWindow. Some of those morphs reference the ContextVariablesInspector as their model).
Anyhow, it should be safe to send EventManager>>cleanUp: with argument true (actionMaps and their contents get recreated on demand), which will release those entries and allow the garbage collector to collect the SystemWindows, other morphs and the Debugger instances.

Note that this is probably not an issue in later versions (e.g. 3.0 doesn’t include EventManager anymore) but it might be relevant for later 1.x versions.

Max


On 21.06.2014, at 20:44, Max Leske <[hidden email]> wrote:


On 21.06.2014, at 18:53, Marcus Denker <[hidden email]> wrote:


On 21 Jun 2014, at 17:36, kilon alios <[hidden email]> wrote:

First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  


I am IRC when at work (and not forgetting to start the IRC client). But often when people ask questions it is exactly the wrong moment in time.
I just *can’t*  instantly drop what I am doing an tend to the IRC channel… I really wonder how people do it… do they really stop their work right in the
miiddle to answer questions? How are they productive? 

I fully agree. I was just momentarily pissed off :)


Marcus




Reply | Threaded
Open this post in threaded view
|

Re: SystemWindow instances can't be garbage-collected

Max Leske

On 24.06.2014, at 15:30, Max Leske <[hidden email]> wrote:

For documentation purposes, this is what I found to be necessary to really clean all window instances. Note that this only works reliably when invoked from a non-UI process (e.g. via WAKom).


cleanupWindows
"in general: the gabage collector seems to be unable to resolve all circular dependencies with weak pointers.
This forces us to explicitly remove the weak pointers to enable garbage colltection.
It also seems to be a problem to invoke the cleanup from within a UI process (e.g. from a workspace). 
Ergo: 
- when invoked from a workspace not all instances may be garbage collected
- when invoked from a non UI process (e.g. WAKom) all instances should have been collected
- performning a manual garbage collection after having invoked this code from a workspace will
(usually) remove the pending instances (new process context)"
| count |
count := 1.
self
cleanupEvents;

I forgot: #cleanupEvents is simply “EventManager cleanUp: true”

cleanupWorkspaces;
cleanupSystemWindows.
[ Smalltalk garbageCollect. count := count + 1 ] doWhileFalse: [
SystemWindow allSubInstances isEmpty or: [ count > 5 "arbitrary number" ] ]

cleanupWorkspaces
PluggableTextMorph allSubInstances do: [ :each | each  
hasUnacceptedEdits: false;
askBeforeDiscardingEdits: false;
myDependents: nil ]

cleanupSystemWindows
[ [ SystemWindow allSubInstances do: [ :window |
window 
makeClosable;
delete ] ] 
on: Error 
do: [ :ex | 
"may get here because we're trying to delete a window which has been deleted already."
ex return  ].
Smalltalk garbageCollect.
"already deleted but still hanging aroung (also see #cleanupEvents and #cleanupWorkspaces)"
SystemWindow allSubInstances 
select: [ :e | e model isNil and: [ e owner isNil ] ]
thenDo: [ :e |
"clean some known places where references can prevent GC"
UITheme current focusIndicator: nil.
ActiveHand mouseOverHandler initialize.
ActiveHand keyboardFocus: nil.
World cleanseStepList.
"e.g. Workspace has a dependents array wich can point to the window"
(PointerFinder pointersTo: e) do: [ :p | 
p class = DependentsArray ifTrue: [
"the first pointer is the 'main' pointer in about 99% of the cases"
(PointerFinder pointersTo: p) first removeDependent: e ] ] ] 
] on: Error do: [ "ignore” ]


On 21.06.2014, at 23:11, Max Leske <[hidden email]> wrote:

Found the problem, documenting it here in case anybody else ever needs this (remember, this is 1.1.1).

Open a debugger (e.g. by evaluating 1/0), then click into the lower right workspace and type something. OCompletion will now have added an entry to the EventManager actionMap with a ContextVariablesInspector instance as the key. There seems to be a cycle there that can’t be resolved by the garbage collector, since I wasn’t able to find any non weak global pointers (an OContext is referenced by an MessageSend in the action map. The OContext references a morph which is connected to the SystemWindow. Some of those morphs reference the ContextVariablesInspector as their model).
Anyhow, it should be safe to send EventManager>>cleanUp: with argument true (actionMaps and their contents get recreated on demand), which will release those entries and allow the garbage collector to collect the SystemWindows, other morphs and the Debugger instances.

Note that this is probably not an issue in later versions (e.g. 3.0 doesn’t include EventManager anymore) but it might be relevant for later 1.x versions.

Max


On 21.06.2014, at 20:44, Max Leske <[hidden email]> wrote:


On 21.06.2014, at 18:53, Marcus Denker <[hidden email]> wrote:


On 21 Jun 2014, at 17:36, kilon alios <[hidden email]> wrote:

First off:
<rant>why do we have an IRC channel if nobody seems to be listening??</rant>

too small community for an irc channel. My experience with irc is that 90-99% of people logged in at least are idle. For its size #pharo is quite active actually.  


I am IRC when at work (and not forgetting to start the IRC client). But often when people ask questions it is exactly the wrong moment in time.
I just *can’t*  instantly drop what I am doing an tend to the IRC channel… I really wonder how people do it… do they really stop their work right in the
miiddle to answer questions? How are they productive? 

I fully agree. I was just momentarily pissed off :)


Marcus