|
From: Samuele P. <pe...@in...> - 2001-01-23 02:10:02
|
Hi.
[me]
>....
> In this case the listener function hold a ref to the source object, to solve
> this the table should (carefully) use weak-refs for values
> too. In the meantime this kind of code can be avoided given that events come
> with source info.
>
In a private discussion with Rich and Finn the following type of code has been
recalled:
class Button1(java.awt.Button):
def __init__(self):
self.actionPerformed = self.action
def action(self):
pass
b=Button1()
More complex components behaviour is customized this way - very often I
imagine. It's a natural style that I used too, and I just forgot about it.
Clearly setting
self.actionPerformed to a bound method (contains a ref to self) prevent gc as
in the example I previously presented.
Asking to avoid this kind of coding is asking too much. So I have committed a
patch along my proposal, that allows b to be collected.
Important things:
- WeakHashMap use for adapters was and now the new patch is always enabled
under java2 (no need to set internalTablesImpl for that - this option is really
only related to class unloading, not adapters gc).
- b would remain stuck in memory (no gc) also under JPython 1.1 and this will
continue to happen also with jython under java 1.1 - I see no way to avoid
that.
regards, Samuele Pedroni.
|