Article View: borland.public.jbuilder.java.swing
Article #8725thread and/or OutOfMemory pb
From: JPBallet
Date: Tue, 25 Jul 2000 00:00
Date: Tue, 25 Jul 2000 00:00
62 lines
2504 bytes
2504 bytes
Dear all,
I create an application which read all gif image in a directory and
animate them with a Runnable class
AnimImage1 animIm1 = new AnimImage1("image\\satetir",);
jPlaceImage.add(animIm1);
animIm1.start();
......................
AnimImage1 animIm1 = new AnimImage1("image\\satetfr");
jPlaceImage.add(animIm1);
animIm1.start();
.................................
AnimImage1 animIm1 = new AnimImage1("image\\radar");
jPlaceImage.add(animIm1);
animIm1.start();
..........................
and so on .
All Thread are executed with a JButton action. An i stop each Thread before
create a new.
I use a mediatracker and a array of image.
my first question is why the memory regulary increase after each thread?
is a mediatracker reason ???
After a certain time, i decide to display an image,rotated and scaled
and i have the message following.
java.lang.awt.OutOfMemory
> at.java.awt.EventQueue.dispatchEvent(EventQueue.java:258)
> at.java.EventDispatchThread.run(EventDispatch.Thread:68)
my code is:
public void paint(Graphics g)
{
Graphics g2 =(Graphics2D)g;
Dimension d = this.getSize();
// On test si l'image est plus grande que la fenetre qui va la recevoir
// si c'est le cas on essaye de la r๏ฟฝduire
int largeurImage,hauteurImage;
int largeurCadre,hauteurCadre;
largeurImage=image.getWidth(null);
hauteurImage=image.getHeight(null);
largeurCadre=d.width;
hauteurCadre=d.height;
double scale=(double)hauteurCadre/(double)image.getHeight(null);
if(image.getWidth(null) > image.getHeight(null)) {
scale =(double)hauteurCadre/(double)image.getHeight(null);
}
AffineTransform at = new AffineTransform();
if(scale < 1.0) at.scale(scale,scale);
at.rotate(Math.PI / 2.0);
at.translate(0,-largeurCadre/scale);
g2D.drawImage(image,at,this) ;
g2D.dispose();
return;
}
the reason of my problem is probably that the painting code can't be
executed quickly.
is that true? and how can i resolve that efficiently?
thank's
JP BALLET
Technical Details
Message-ID:
<8ljpue$ie25@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,7563759ce3971522,start X-Google-Attributes: gid111d45,public From: "JPBallet" <jean-pierre.ballet@meteo.fr> Subject: thread and/or OutOfMemory pb Date: 2000/07/25 Message-ID: <8ljpue$ie25@bornews.borland.com> X-Deja-AN: 650491376 Organization: METEO-FRANCE X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: borland.public.jbuilder.java.swing