- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Probable memory leak in scala.swing.Table
Sat, 2008-12-20, 15:11
I'm not sure this is the proper forum, but after some hour of JProbe and
tackling an annoying leak in my application, I am positive there is a bug in
how individual cell are created. Any operation I do on the table, such as
selecting a row or cell, will create new renderer. I believe this is the
correct behaviour. I believe the problem is that the renderer gets placed
into a scala.swing.Component, and these components have registered listener,
so SWING/AWT end up having strong references to them, and that makes them
linger on forever.
On JProbe (I only get the class name, not the scala name), I noticed a huge
number of objects in the use cases (all with the same number of instances):
scala.swing.Table$$anon$3
Referrring to the object above are:
scala.swing.Component$$anon$7
scala.swing.Component$$anon$12
scala.swing.Component$$anon$6
Referring to scala.swing.Component$$anon$6 are :
java.awt.AWTEventMulticaster
These guys are used to register listener. If you look into
scala.swing.Component it registers actions.
I tried to nail down the actual problem,I think that it boils down to this:
1) Something happens on the table (selecting something for example)
2) rendererComponent of Table is called, this gives a new Object to render
the cell, this gets bumped to a component.
3) Component registers a set of listener
4) JTable throw away the components, but the listener keep them alive.
This also explains the slowing of the interface I noticed after a long
running session.
I wander if there is a workaround for this, I am considering dropping
scala.swing.Table if there is no other alternative.
I thought maybe Component could have a constructor that does not set the
listeners. Or a way of unregistering them. Any other alternatives?
Thomas
tackling an annoying leak in my application, I am positive there is a bug in
how individual cell are created. Any operation I do on the table, such as
selecting a row or cell, will create new renderer. I believe this is the
correct behaviour. I believe the problem is that the renderer gets placed
into a scala.swing.Component, and these components have registered listener,
so SWING/AWT end up having strong references to them, and that makes them
linger on forever.
On JProbe (I only get the class name, not the scala name), I noticed a huge
number of objects in the use cases (all with the same number of instances):
scala.swing.Table$$anon$3
Referrring to the object above are:
scala.swing.Component$$anon$7
scala.swing.Component$$anon$12
scala.swing.Component$$anon$6
Referring to scala.swing.Component$$anon$6 are :
java.awt.AWTEventMulticaster
These guys are used to register listener. If you look into
scala.swing.Component it registers actions.
I tried to nail down the actual problem,I think that it boils down to this:
1) Something happens on the table (selecting something for example)
2) rendererComponent of Table is called, this gives a new Object to render
the cell, this gets bumped to a component.
3) Component registers a set of listener
4) JTable throw away the components, but the listener keep them alive.
This also explains the slowing of the interface I noticed after a long
running session.
I wander if there is a workaround for this, I am considering dropping
scala.swing.Table if there is no other alternative.
I thought maybe Component could have a constructor that does not set the
listeners. Or a way of unregistering them. Any other alternatives?
Thomas
Sat, 2008-12-20, 16:17
#2
Re: Probable memory leak in scala.swing.Table
On Sat, Dec 20, 2008 at 12:55 PM, Ingo Maier <ingo.maier@epfl.ch> wrote:
Please file a ticket for that.
Will do, but is this to be done on:
https://lampsvn.epfl.ch/trac/scala/newticket
Which component?
It's definetely a leak with regards, I implemented an alternative sub class of Table and it worked much better. Will report on the track?
Thomas
Sat, 2008-12-20, 16:27
#3
Re: Probable memory leak in scala.swing.Table
Thomas Sant Ana wrote:
>
>
> On Sat, Dec 20, 2008 at 12:55 PM, Ingo Maier wrote:
>
> Please file a ticket for that.
>
>
> Will do, but is this to be done on:
>
> https://lampsvn.epfl.ch/trac/scala/newticket
>
> Which component?
Library. Thanks for reporting.
Ingo
>
> It's definetely a leak with regards, I implemented an alternative sub
> class of Table and it worked much better. Will report on the track?
>
> Thomas
Sat, 2008-12-20, 16:47
#4
Re: Probable memory leak in scala.swing.Table
On Sat, Dec 20, 2008 at 1:15 PM, Ingo Maier <ingo.maier@epfl.ch> wrote:
Thomas Sant Ana wrote:
On Sat, Dec 20, 2008 at 12:55 PM, Ingo Maier <ingo.maier@epfl.ch> wrote:
Please file a ticket for that.
Will do, but is this to be done on:
https://lampsvn.epfl.ch/trac/scala/newticket
Which component?
Library. Thanks for reporting.
I created the ticket:
https://lampsvn.epfl.ch/trac/scala/ticket/1595
Also attached my local workaround.
Thomas
Sat, 2008-12-20, 16:57
#5
Re: Probable memory leak in scala.swing.Table
On Sat, Dec 20, 2008 at 1:15 PM, Ingo Maier <ingo.maier@epfl.ch> wrote:
Thomas Sant Ana wrote:
On Sat, Dec 20, 2008 at 12:55 PM, Ingo Maier <ingo.maier@epfl.ch> wrote:
Please file a ticket for that.
Will do, but is this to be done on:
https://lampsvn.epfl.ch/trac/scala/newticket
Which component?
Library. Thanks for reporting.
I created the ticket:
https://lampsvn.epfl.ch/trac/scala/ticket/1595
Also attached my local workaround.
Thomas
Please file a ticket for that.
Thanks,
Ingo
Thomas Sant Ana wrote:
> I'm not sure this is the proper forum, but after some hour of JProbe and
> tackling an annoying leak in my application, I am positive there is a bug in
> how individual cell are created. Any operation I do on the table, such as
> selecting a row or cell, will create new renderer. I believe this is the
> correct behaviour. I believe the problem is that the renderer gets placed
> into a scala.swing.Component, and these components have registered listener,
> so SWING/AWT end up having strong references to them, and that makes them
> linger on forever.
>
> On JProbe (I only get the class name, not the scala name), I noticed a huge
> number of objects in the use cases (all with the same number of instances):
>
> scala.swing.Table$$anon$3
>
> Referrring to the object above are:
>
> scala.swing.Component$$anon$7
> scala.swing.Component$$anon$12
> scala.swing.Component$$anon$6
>
> Referring to scala.swing.Component$$anon$6 are :
>
> java.awt.AWTEventMulticaster
>
> These guys are used to register listener. If you look into
> scala.swing.Component it registers actions.
>
> I tried to nail down the actual problem,I think that it boils down to this:
>
> 1) Something happens on the table (selecting something for example)
> 2) rendererComponent of Table is called, this gives a new Object to render
> the cell, this gets bumped to a component.
> 3) Component registers a set of listener
> 4) JTable throw away the components, but the listener keep them alive.
>
> This also explains the slowing of the interface I noticed after a long
> running session.
>
> I wander if there is a workaround for this, I am considering dropping
> scala.swing.Table if there is no other alternative.
>
> I thought maybe Component could have a constructor that does not set the
> listeners. Or a way of unregistering them. Any other alternatives?
>
>
> Thomas