×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    36

    Smile lcdui.Image.createImage -> java.lang.OutOfMemoryError: Java heap space

    Hi all
    I'm on a program of reading incoming images which comes as byte arrays through a socket and convert them back to images at j2me client using the following method.

    Code:
    javax.microedition.lcdui.Image.createImage();
    The programs works fine for some time. But after few minutes it prints the error
    java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.BufferedImage.getRGB(Unknown Source)
    at com.sun.kvem.midp.GraphicsBridge.loadImage(Unknown Source)
    at com.sun.kvem.midp.GraphicsBridge.createImageFromData(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.kvem.sublime.MethodExecution.process(Unknown Source)
    at com.sun.kvem.sublime.SublimeExecutor.processRequest(Unknown Source)
    at com.sun.kvem.sublime.SublimeExecutor.run(Unknown Source)
    Folowing is client code method (it's a thread)
    Code:
    public void run()
        {
            super.run();
            short length;
     
            while (true)
            {
                DataInputStream din = null;
                try
                {
                    din = new DataInputStream(in);
     
                    length = din.readShort();	// to determine next data packet size
     
                    byte[] arr = new byte[length];  // next data packet store here
     
                    din.readFully(arr);  //read image
    
     
                    //#####################################
                    img = Image.createImage(arr, 0, arr.length);
                    //#####################################
     
                    canvas.setImage(img);
                    
                    ChangeImage.sleep(50);
                }
                catch (Exception ex)
                {
                    ex.printStackTrace();
                }
            }
        }
    Reading of byte arrays through socket communication works fine and they contain no problem.

    But problem is

    Code:
    img = Image.createImage(arr, 0, arr.length);
    When I comment the above line it works fine for indefinite time period. No problem at all.

    I need to know that whether it's not flush old images?
    Or are there any other method to convert byte array to images?

    Please help me.

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: lcdui.Image.createImage -> java.lang.OutOfMemoryError: Java heap space

    What happens in "canvas.setImage()"?

    What is the size of the array?

    What is the size of the image that fails (in pixels, not bytes)?

    What are you running this on?

    Cheers,
    Graham.

Similar Threads

  1. Replies: 4
    Last Post: 2009-01-06, 08:39
  2. How to increase the jave heap space in mobile phones
    By prats123 in forum Mobile Java General
    Replies: 2
    Last Post: 2008-04-02, 05:55
  3. Has Nokia broken 7650 J2ME in v4.39?
    By LongSteve in forum Mobile Java General
    Replies: 6
    Last Post: 2003-06-03, 17:05
  4. Replies: 5
    Last Post: 2003-02-07, 11:25
  5. 7650 and MS Bluetooth Transceiver
    By damnedi in forum Bluetooth Technology
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

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