git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: Re: [EGIT PATCH 3/8] Dispose of allocated colors on finalize()
Date: Wed, 1 Oct 2008 07:37:18 -0700	[thread overview]
Message-ID: <20081001143718.GU21310@spearce.org> (raw)
In-Reply-To: <1222818823-22780-3-git-send-email-robin.rosenberg@dewire.com>

Robin Rosenberg <robin.rosenberg@dewire.com> wrote:
> ---

Missing SBO.

>  .../egit/ui/internal/history/SWTPlotRenderer.java  |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/SWTPlotRenderer.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/SWTPlotRenderer.java
> index 23ec255..a58b3bf 100644
> --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/SWTPlotRenderer.java
> +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/SWTPlotRenderer.java
> @@ -45,6 +45,17 @@ SWTPlotRenderer(final Display d) {
>  		sys_darkblue = d.getSystemColor(SWT.COLOR_DARK_BLUE);
>  	}
>  
> +	@Override
> +	protected void finalize() throws Throwable {
> +		sys_black.dispose();
> +		sys_blue.dispose();
> +		sys_gray.dispose();
> +		sys_darkblue.dispose();
> +		sys_yellow.dispose();
> +		sys_green.dispose();
> +		sys_white.dispose();
> +	}

I think this is wrong.  Any color that we get from
Display.getSystemColor() must not be disposed of by the application,
its in use by the Display and/or other parts of the application.

>From the Javadocs:

  This color should not be free'd because it was allocated by the
  system, not the application.

I take that to mean that the color should not be disposed of.

Though reading the Gtk SWT sources it seems that the system color
objects aren't pooled, each call to getSystemColor causes a new
Color instace to be allocated.  So it may be harmless on Gtk.

What was the rationale for disposing of these resources?  Did you
identify that this is a resource leak somewhere?  Because I'd like
to make sure I actually understand the SWT resource model better
so I don't commit mistakes in the future.

-- 
Shawn.

  parent reply	other threads:[~2008-10-01 14:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30 23:53 [EGIT PATCH 1/8] Set table row height for the glog JTable Robin Rosenberg
2008-09-30 23:53 ` [EGIT PATCH 2/8] Move AWTPlotRenderer to its own file Robin Rosenberg
2008-09-30 23:53   ` [EGIT PATCH 3/8] Dispose of allocated colors on finalize() Robin Rosenberg
2008-09-30 23:53     ` [EGIT PATCH 4/8] Align commit text properly in jgit glog Robin Rosenberg
2008-10-01  0:02       ` Robin Rosenberg
2008-10-01 14:38       ` Shawn O. Pearce
2008-10-01 19:31         ` [EGIT PATCH 0/3] jgit glog alignment fixes Robin Rosenberg
2008-10-01 19:31           ` [EGIT PATCH 1/3] Set table row height for the glog JTable Robin Rosenberg
2008-10-01 19:31             ` [EGIT PATCH 2/3] Move AWTPlotRenderer to its own file Robin Rosenberg
2008-10-01 19:31               ` [EGIT PATCH 3/3] Align commit text properly in jgit glog Robin Rosenberg
2008-10-01 14:37     ` Shawn O. Pearce [this message]
2008-10-01 17:48       ` [EGIT PATCH 3/8] Dispose of allocated colors on finalize() Robin Rosenberg
2008-10-01 14:32   ` [EGIT PATCH 2/8] Move AWTPlotRenderer to its own file Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081001143718.GU21310@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).