This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: heap allocation and gc with gcj
- From: Andrew Haley <aph at redhat dot com>
- To: Bryce McKinlay <mckinlay at redhat dot com>
- Cc: Vladimir Leven <vladimirl at wrx-ca dot com>, java at gcc dot gnu dot org
- Date: Wed, 5 May 2004 09:43:22 +0100
- Subject: Re: heap allocation and gc with gcj
- References: <40633001.3090605@wrx-ca.com><408935D7.2060600@wrx-ca.com><408E92C7.9090302@wrx-ca.com><4098164C.7050303@wrx-ca.com><40981FEB.3060300@redhat.com>
Bryce McKinlay writes:
> Vladimir Leven wrote:
>
> > Using GCJ (3.2.2) If I do the following in a loop:
> >
> > while (true) {
> > byte[] bytes = new byte[1024];
> > //do some unrelated stuff
> > bytes = null;
> > }
> >
> > Will the array be allocated each time the loop runs or will the
> > compiler remove it because it is not used in the method?
>
> No, GCJ is not yet smart enough to do this sort of optimization. It
> shouldn't be too difficult to add, however, with the tree-ssa framework.
Hmm. This requires some fairly subtle escape analysis in all but the
simplest cases.
> But, we tend to assume that developers are smart enough to not write
> such code - there are other areas where smarter optimizations by the
> compiler should yield broader benefits - type and bounds check
> elimination, for example.
I agree.
Andrew.