Results 1 to 3 of 3
  1. #1
    KKDoWniNg84 is offline Member
    Join Date
    Jul 2008
    Posts
    2
    Rep Power
    0

    Default 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

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default

    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.

  3. #3
    KKDoWniNg84 is offline Member
    Join Date
    Jul 2008
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    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?
    Thanks for your answers...Bye!

Similar Threads

  1. Socket
    By vortex in forum New To Java
    Replies: 2
    Last Post: 05-25-2008, 07:41 AM
  2. Socket Closed!
    By rameshraj in forum Networking
    Replies: 0
    Last Post: 05-06-2008, 12:48 PM
  3. Socket Closed!
    By rameshraj in forum Networking
    Replies: 0
    Last Post: 05-06-2008, 11:11 AM
  4. How To Make Socket Connection
    By madhumurundi in forum Networking
    Replies: 5
    Last Post: 04-21-2008, 07:05 PM
  5. XML through a socket
    By Heather in forum XML
    Replies: 2
    Last Post: 07-04-2007, 10:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •