G
Guest
All:
I've done some more digging into the OOME I'm getting on
an OSF1 platform, and here's an even simplier example that'll
fail every time. I would be much obliged if someone can post
a change to the Display.java code below that will fix things
up. (Roedy's reference link on Ratpacking was helpful, but just
slowed up receipt of the OOME by a little.)
% uname -a
OSF1 sys1 V5.1 1885 alpha
% java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition
Fast VM (build 1.4.1-2, native threads, mixed mode, 06/18/2003-17:51)
% java -Xverbosegc:file_gcDump Display
<GC: Growing heap from 200.0MPB to 532.0MB>
<GC: Growing heap from 532.0MB to 1024.0MB>
java.lang.OutOfMemoryError
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
...
at Display$DisplayPanel.paintComponent(Display.java:20)
...
% tail -12 gdDump
<GC: Garbage Collection #9 with 1024.00 MB Heap (Compacting)>
<GC: Time since last collection : 0.02 seconds>
<GC: Time spent collecting : 0.43 seconds>
<GC: Data live before collection : 1023.80 MB>
<GC: Data live after collection : 1023.80 MB>
<GC: Data pinned during collection : 1020.47 MB>
<GC: Garbage Collection #10 with 1024.00 MB Heap (Compacting)>
<GC: Time since last collection : 0.00 seconds>
<GC: Time spent collecting : 0.44 seconds>
<GC: Data live before collection : 1023.80 MB>
<GC: Data live after collection : 1023.80 MB>
<GC: Data pinned during collection : 1020.48 MB>
% cat Display.java
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.swing.*;
class Display extends JFrame
{
static BufferedImage bi = new BufferedImage (100, 200,
BufferedImage.TYPE_INT_ARGB);
static Rectangle r;
class DisplayPanel extends JPanel
{
public void paintComponent (Graphics g)
{
if (bi == null)
return;
r = getBounds ();
g.clearRect (0, 0, r.width, r.height);
g.drawImage (bi, 0, 0, r.width, r.height,
Color.black, null); // line 20
bi.flush ();
r = null;
}
}
Display ()
{
super ();
DisplayPanel dp = new DisplayPanel ();
getContentPane ().add (dp);
setSize (200, 300);
setVisible (true);
int rgb[] = new int[100*200];
int alpha = 0xff000000;
int shade = 50;
int inc = 1;
while (true)
{
int val = alpha + (shade << 16) + (shade << 8) + shade;
for (int i = 0; i < rgb.length; i++)
rgb = val;
shade += inc;
if (shade < 50 || shade > 250)
inc *= -1;
bi.setRGB (0, 0, 100, 200, rgb, 0, 100);
dp.repaint ();
}
}
public static void main (String args[])
{
new Display ();
}
}
The GC log file shows that memory continues to be allocated
but not reclaimed; indeed, the vast majority of it is pinned
for some mysterious reason. The first 8 entries show the
before & after values to be almost identical with the pinned
amounts very close nearby. Here are the values, the first
number being the before and second being the pinned:
#1 200MB heap: 187.22, 198.08
#2 532MB heap: 510.78, 528.81
#3 532MB heap: 530.77, 528.83
#4 1024MB heap: 992.42, 1020.17
#5 1024MB heap: 1023.77, 1020.44
#6 1024MB heap: 1023.75, 1020.42
#7 1024MB heap: 1023.80, 1020.41
#8 1024MB heap: 1023.77, 1020.39
I'm guessing that the two printed GC lines that appeared on
the screen occurred between #1 & #2, and #2 & #3.
Some of the things I've tried include adding an ImageObserver
class as the displayImage call's last arg, but every notification
received has the ALLBITS set with no other flags. I've tried
creating a Runnable class for the setRGB and repaint calls, and
then giving this Object to invokeLater and invokeAndWait. I've
tried getting the currentThread and forcing sleeps and yields,
and worsening the priority. I've tried putting a System.gc call
after each line in the above program, and running it with the
-Xmx<lots> option. But, all these tests lead to the same nasty
OOME.
It's a shame that a lot of the source files in java.awt.image
contain non-public vars, methods, constructors, etc; otherwise
it'd be possible (with a lot of work!) to extend Raster and
DataBufferInt, add some additional debug println's and try to
figure out what's going on. Depending on, I don't know, the
phase of the moon or the stock market, the program will display
something like 2300 or so images before tossing the OOME; but
it always occurs at line 41 of DataBufferInt.java which
declares a new int array of size width*height.
I can't get the above program to fail on my Windoze PC although
I've let it run for hours, and I'm starting to think that there
is an implementation problem with OSF1's JVM. Any help would be
very much appreciated,
I've done some more digging into the OOME I'm getting on
an OSF1 platform, and here's an even simplier example that'll
fail every time. I would be much obliged if someone can post
a change to the Display.java code below that will fix things
up. (Roedy's reference link on Ratpacking was helpful, but just
slowed up receipt of the OOME by a little.)
% uname -a
OSF1 sys1 V5.1 1885 alpha
% java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition
Fast VM (build 1.4.1-2, native threads, mixed mode, 06/18/2003-17:51)
% java -Xverbosegc:file_gcDump Display
<GC: Growing heap from 200.0MPB to 532.0MB>
<GC: Growing heap from 532.0MB to 1024.0MB>
java.lang.OutOfMemoryError
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
...
at Display$DisplayPanel.paintComponent(Display.java:20)
...
% tail -12 gdDump
<GC: Garbage Collection #9 with 1024.00 MB Heap (Compacting)>
<GC: Time since last collection : 0.02 seconds>
<GC: Time spent collecting : 0.43 seconds>
<GC: Data live before collection : 1023.80 MB>
<GC: Data live after collection : 1023.80 MB>
<GC: Data pinned during collection : 1020.47 MB>
<GC: Garbage Collection #10 with 1024.00 MB Heap (Compacting)>
<GC: Time since last collection : 0.00 seconds>
<GC: Time spent collecting : 0.44 seconds>
<GC: Data live before collection : 1023.80 MB>
<GC: Data live after collection : 1023.80 MB>
<GC: Data pinned during collection : 1020.48 MB>
% cat Display.java
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.swing.*;
class Display extends JFrame
{
static BufferedImage bi = new BufferedImage (100, 200,
BufferedImage.TYPE_INT_ARGB);
static Rectangle r;
class DisplayPanel extends JPanel
{
public void paintComponent (Graphics g)
{
if (bi == null)
return;
r = getBounds ();
g.clearRect (0, 0, r.width, r.height);
g.drawImage (bi, 0, 0, r.width, r.height,
Color.black, null); // line 20
bi.flush ();
r = null;
}
}
Display ()
{
super ();
DisplayPanel dp = new DisplayPanel ();
getContentPane ().add (dp);
setSize (200, 300);
setVisible (true);
int rgb[] = new int[100*200];
int alpha = 0xff000000;
int shade = 50;
int inc = 1;
while (true)
{
int val = alpha + (shade << 16) + (shade << 8) + shade;
for (int i = 0; i < rgb.length; i++)
rgb = val;
shade += inc;
if (shade < 50 || shade > 250)
inc *= -1;
bi.setRGB (0, 0, 100, 200, rgb, 0, 100);
dp.repaint ();
}
}
public static void main (String args[])
{
new Display ();
}
}
The GC log file shows that memory continues to be allocated
but not reclaimed; indeed, the vast majority of it is pinned
for some mysterious reason. The first 8 entries show the
before & after values to be almost identical with the pinned
amounts very close nearby. Here are the values, the first
number being the before and second being the pinned:
#1 200MB heap: 187.22, 198.08
#2 532MB heap: 510.78, 528.81
#3 532MB heap: 530.77, 528.83
#4 1024MB heap: 992.42, 1020.17
#5 1024MB heap: 1023.77, 1020.44
#6 1024MB heap: 1023.75, 1020.42
#7 1024MB heap: 1023.80, 1020.41
#8 1024MB heap: 1023.77, 1020.39
I'm guessing that the two printed GC lines that appeared on
the screen occurred between #1 & #2, and #2 & #3.
Some of the things I've tried include adding an ImageObserver
class as the displayImage call's last arg, but every notification
received has the ALLBITS set with no other flags. I've tried
creating a Runnable class for the setRGB and repaint calls, and
then giving this Object to invokeLater and invokeAndWait. I've
tried getting the currentThread and forcing sleeps and yields,
and worsening the priority. I've tried putting a System.gc call
after each line in the above program, and running it with the
-Xmx<lots> option. But, all these tests lead to the same nasty
OOME.
It's a shame that a lot of the source files in java.awt.image
contain non-public vars, methods, constructors, etc; otherwise
it'd be possible (with a lot of work!) to extend Raster and
DataBufferInt, add some additional debug println's and try to
figure out what's going on. Depending on, I don't know, the
phase of the moon or the stock market, the program will display
something like 2300 or so images before tossing the OOME; but
it always occurs at line 41 of DataBufferInt.java which
declares a new int array of size width*height.
I can't get the above program to fail on my Windoze PC although
I've let it run for hours, and I'm starting to think that there
is an implementation problem with OSF1's JVM. Any help would be
very much appreciated,