RE: garbage collection take too much time to execute....
"Boehm, Hans" <[email protected]>
| Newsgroups | gmane.comp.gcc.java.devel |
|---|---|
| Message-ID | <238A96A773B3934685A7269CC8A8D0420AE7D74F53@GVW0436EXB.americas.hpqcorp.net> |
Did you try with a recent version of gcj? In the past, there have been problems with the collector looking for pointers in graphics memory. You can try running the program with the GC_DUMP_REGULARLY environment variable set, and look at the size of the root sets. If it appears to include your graphics memory, then that's probably the issue. If not, GC_PRINT_STATS output might be helpful. Hans > -----Original Message----- > From: [email protected] [mailto:[email protected]] > On Behalf Of - - > Sent: Tuesday, June 17, 2008 8:23 AM > To: [email protected] > Cc: [email protected] > Subject: garbage collection take too much time to execute.... > > > Hi, > I found a strange behaviour on code generated by gcj when > compare its output with code generated by eclipse. > > Mainly the code generated by gcj take too much time to > perform a memory garbage collection (about 5 seconds) > instead of only 15 milliseconds of byte code generated by eclipse. > > The problem seems to happens when there are canvas and > transform operations. I attach a simple snippet code that > write a vertical text on canvas in order to reproduce the behaviour. > > The gcj compiler I use is: > $ gcj --version > gcj.exe (GCC) 3.4.5 (mingw-vista special r3) Copyright (C) > 2004 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. > There is NO warranty; not even for MERCHANTABILITY or > FITNESS FOR A PARTICULAR PURPOSE. > > with the swt version 3349: "swt-gdip-win32-3349.dll" and > "swt-win32-3349.dll" > > I'm new of this discussion list, hoping not annoy you. It is > a trouble or it is just a mistake on usage of transform? > thanks you, > > x10 > > Here is the code.... > > ------------------------- > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Canvas; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Transform; > > public class snippet { > > private Shell sShell = null; // > @jve:decl-index=0:visual-constraint="10,10" > private Button button = null; > private Canvas canvas = null; > > /** > * This method initializes canvas > * > */ > private void createCanvas() { > GridData gridData = new GridData(); > gridData.horizontalAlignment = > org.eclipse.swt.layout.GridData.FILL; > gridData.grabExcessHorizontalSpace = true; > gridData.grabExcessVerticalSpace = true; > gridData.verticalAlignment = > org.eclipse.swt.layout.GridData.FILL; > canvas = new Canvas(sShell, SWT.BORDER); > canvas.setLayoutData(gridData); > canvas.addPaintListener(new > org.eclipse.swt.events.PaintListener() { > public void > paintControl(org.eclipse.swt.events.PaintEvent e) { > > System.out.println("paintControl()"); // TODO Auto-generated > Event stub paintControl() > GC gc = e.gc; > > int xVertical = 200; > int yVertical = 200; > Transform t = new > Transform(gc.getDevice()); > t.translate(xVertical, yVertical); > t.rotate(-90f); > gc.setTransform(t); > > gc.drawText("Vertical Text",0,0); > > t.rotate(90f); > t.translate(-xVertical, -yVertical); > gc.setTransform(t); > t.dispose(); > > } > }); > } > > /** > * @param args > */ > public static void main(String[] args) { > // TODO Auto-generated method stub > /* Before this is run, be sure to set up the > launch configuration (Arguments->VM Arguments) > * for the correct SWT library path in order > to run with the SWT dlls. > * The dlls are located in the SWT plugin jar. > * For example, on Windows the Eclipse SWT > 3.1 plugin jar is: > * > installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar > */ > Display display = Display.getDefault(); > snippet thisClass = new snippet(); > thisClass.createSShell(); > thisClass.sShell.open(); > > while (!thisClass.sShell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > } > > /** > * This method initializes sShell > */ > private void createSShell() { > GridData gridData1 = new GridData(); > gridData1.horizontalAlignment = > org.eclipse.swt.layout.GridData.CENTER; > sShell = new Shell(); > sShell.setText("Shell"); > sShell.setSize(new Point(579, 365)); > sShell.setLayout(new GridLayout()); > button = new Button(sShell, SWT.NONE); > button.setText("Press me to redraw the canvas"); > button.setLayoutData(gridData1); > button.addSelectionListener(new > org.eclipse.swt.events.SelectionAdapter() { > public void > widgetSelected(org.eclipse.swt.events.SelectionEvent e) { > > System.out.println("widgetSelected()"); // TODO > Auto-generated Event stub widgetSelected() > > canvas.redraw(); > System.err.println("start"); > long before = > System.currentTimeMillis(); > System.gc(); > long after = > System.currentTimeMillis(); > System.err.println("Elapsed > milliseconds: " + (after-before)); > System.err.println("end"); > } > }); > createCanvas(); > } > > } > ---------------------------- > > > > > > > > > > > The java code attached is > > > >