Community Forums

Home » Vuze Forums » Development » Bug Reports


Thread: SWT Font leaks


Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 1 - Pages: 1 - Last Post: Jan 4, 2008 12:37 PM Last Post By: TuxPaper
yahave

Posts: 5
Registered: 12/26/07
SWT Font leaks
Posted: Jan 4, 2008 7:16 AM
  Click to reply to this thread Reply
Running Azureus, it seems that a large number of fonts are created and never disposed.
I tracked the problem down to the two methods getFontHeightFromPX(...) in org.gudy.azureus2.ui.swt.Utils.
As far as I could tell, these methods create multiple Font instances in order to find an appropriate font size. The Fonts are created in a loop, and all iterations but the last one properly dispose the Font created. These methods are called pretty frequently, and each call leaks a single Font object.

The bug in these methods is probably "inspired" by copying the code from a method that returns the font itself and not only its size (e.g., getFontWithHeight in the same class).

The fix is easy, adding "if (font != null) font.dispose();" to the finally block after the gc has been disposed.
TuxPaper

Posts: 163
Registered: 11/13/07
Re: SWT Font leaks
Posted: Jan 4, 2008 12:37 PM   in response to: yahave in response to: yahave
  Click to reply to this thread Reply
Thanks for catching the resource leak! :D
Legend
Master: 200 - 999 pts
Expert: 150 - 199 pts
Advanced: 100 - 149 pts
Intermediate: 50 - 99 pts
Beginner: 10 - 49 pts
Newbie: 0 - 9 pts
Vuze Staff Member
Vuze Project Developer
Vuze Community Moderator
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums