SWT Images via socket
Hello everyone, i'am new in the forum then i say hello to everyone. Excuse me but i'm italian and i know less english, i hope that you understand my problem. I have written a java program written with a GUI SWT. This program receive JPEG images via socket then i have received and draw these images in this way:
JPEGDecoder decoder = JPEGCodec.createJPEGDecoder(in);
BufferedImage img = decoder.decodeAsBufferedImage();
Image image = new Image(Display.getCurrent(), converter.convertToSWT(img));
pencil.drawImage(image, 0, 0);
All this code run in a loop For( ; ; ) and it work fine but there is a problem, every time that it receive an image via socket it make the instruction new Image... and this increments the memory used. I have tried in all ways and i don't found nothing that help me. Do you know a solution for my problem? There is another way to generate an Image (without "new") or there is another JPEGDecoder that generates an Image SWT??
Please answers me because i need an help!!! :confused::confused:
Thanks in advance and Bye to everyone!!!:o
Do you only want to keep the last image read and to get rid of the ones that were read earlier?
Would the flush() method on old images get rid of the memory being used?
Sometime garbage collection should retrieve the storage used by the objects if they are no longer referenced.
Excuse me Norm i haven't understand well yours questions. But what i want is create a new Image without using "new" operator but simply modifying the first image with some methods as "image.set..." . Understand?
Originally Posted by Norm
Thanks for your answers...Bye!