Fully featured low overhead profiler for Java EE and Java SE platforms.
Performance monitoring and profiling of Jenkins, TeamCity, Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Inspection: Lost SWT controls

Moderators: Vladimir Kondratyev, Anton Katilin

Inspection: Lost SWT controls

Postby Mark Christiaens » Wed Mar 11, 2020 2:36 pm

I suspect that the inspection "Lost SWT controls" is not behaving as hoped. The help message mentions:
Technically, it finds instances of org.eclipse.swt.widgets.Control which are not accessible from org.eclipse.swt.widgets.Display's field 'controlTable'.

On Linux, there is no field 'controlTable' in Display.java. It is only present in the win32 version of Display.java. Indeed, when I run this analysis on a heap dump of an Eclipse application, it seems to report back that all SWT controls are lost. When I analyse one of those controls in detail, I see that there are paths from the Display object down to the control. These paths seem to start from the 'widgetTable' field in Display.

Another thing I expected was that this analysis would take the 'isDisposed' state into account. When a control is disposed, I suspect it is fine that it is not accessible from Display anymore. The only thing left to do with the control is garbage collection. I would think that only controls that are not reachable from Display and are not disposed should be reported?
Mark Christiaens
 
Posts: 1
Joined: Wed Mar 11, 2020 2:18 pm

Re: Inspection: Lost SWT controls

Postby Anton Katilin » Thu Mar 12, 2020 10:36 am

Hello Mark,

Thank for pointing this out.

The inspection was created many years ago and has not been reviewed since then.

We'll investigate.

Best regards,
Anton
Anton Katilin
 
Posts: 5924
Joined: Wed Aug 11, 2004 8:37 am

Re: Inspection: Lost SWT controls

Postby Anton Katilin » Fri Mar 13, 2020 1:32 pm

Hello Mark,

> When a control is disposed, I suspect it is fine that it is not accessible from Display anymore.
Agree.

> The only thing left to do with the control is garbage collection.
Agree.

> I would think that only controls that are not reachable from Display and are not disposed should be reported?
Do you suggest to report only non-disposed controls, but never report a control which has been disposed?

But if a control is not reachable from Display, disposed, but still reachable from anywhere else i.e. cannot be collected, wouldn't that control be a leak? Are there any cases when it makes sense to keep a disposed control in memory?

Another question (I'm not very much familiar with SWT, we use AWT/Swing): is it technically possible that a control is removed from Display (not reachable from it) but is not disposed?

Best regards,
Anton
Anton Katilin
 
Posts: 5924
Joined: Wed Aug 11, 2004 8:37 am

Re: Inspection: Lost SWT controls

Postby Anton Katilin » Fri Mar 13, 2020 2:47 pm

Update: next build will handle "widgetTable" and therefore solve the problem with Linux snapshots.
Anton Katilin
 
Posts: 5924
Joined: Wed Aug 11, 2004 8:37 am


Return to Java Profiler

Who is online

Users browsing this forum: No registered users and 1 guest

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.