×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Question Out of memory error while calling the createImage()?

    Hi All,

    I am getting the out of memory error while calling the create image method.

    The code snippet is the below and I am getting the exception while executing the last satement.
    The image size is less 15 kb .
    Image width*height=600*800.
    And I am trying in the Nokia series 40 devices and getting the error while netbeans provided emulator its working fine.

    But if the Image width*height<=480*640, then every thing is working fine.

    I have checked the available heap memory and found that is available more than 800kb.Still getting the out of memory exception.


    FileConnection fc = (FileConnection) Connector.open("file://localhost/" + imageFilePath);
    if (!fc.exists()) {
    throw new IOException("File does not exists");
    } else {
    InputStream fis = fc.openInputStream();
    Image image = null;
    ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
    byte imageData[] = new byte[2048];
    while ((fis.read(imageData)) != -1) {
    bStrm.write(imageData);
    }
    // Place into image array
    imageData = null;
    imageData = bStrm.toByteArray();
    // Create the image from the byte array
    fis.close();
    fc.close();
    image = Image.createImage(imageData, 0, imageData.length);


    So can any one please tell me the reason of out of memory error!!!




    Thanks & Regards,
    Ajit

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Out of memory error while calling the createImage()?

    I am getting the out of memory error while calling the create image method.

    The code snippet is the below and I am getting the exception while executing the last satement.
    The image size is less 15 kb .
    Image width*height=600*800.
    And I am trying in the Nokia series 40 devices and getting the error while netbeans provided emulator its working fine.

    But if the Image width*height<=480*640, then every thing is working fine.

    I have checked the available heap memory and found that is available more than 800kb.Still getting the out of memory exception.
    If you image size is 15kb on file system but its width*height=600*800 and 32bit color depth(remember jpg file on filesystem are compressed bytes), then on the heap if you try create Image it will need 600*800*4 bytes = 1920000 bytes i.e. around 1.92MB.

    So you can't create that big image in S40 with 2MB of heap at the max.

    You can also refer to FN Wiki Article - http://wiki.forum.nokia.com/index.ph...y_Usage_Images
    Last edited by ektasrv; 2010-06-24 at 10:33.
    Thanks,
    Ekta

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Out of memory error while calling the createImage()?

    Thanks Ekta for your reply!

    If it is not possible then no problem.
    But How can I avoid the creation of image having larger width*=height.
    Please guide me!!!

    Thanks & Regards,
    Ajit

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Out of memory error while calling the createImage()?

    Quote Originally Posted by ajitkumar26 View Post
    Thanks Ekta for your reply!

    If it is not possible then no problem.
    But How can I avoid the creation of image having larger width*=height.
    Please guide me!!!

    Thanks & Regards,
    Ajit
    As its limitation on limited heap device like S40, Always check if you have the available free memory to create such a big image in J2me.

    It wont be of much use, as you can't display that big image on the Canvas.... so why not create the image out of data equal to the visible screen size only on then if user scrolls to other part fetch that additional image clip.

    Or if you want to display a thumbnail for preview - try to read the thumbnail data from EXIF headers of the JPEG image and create image using that data. or in worst case send the file data to server (a web service) that can create a thumbnail of the screen size and then you catch it on device for future use.
    Thanks,
    Ekta

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Out of memory error while calling the createImage()?

    Hi Ekta,

    Actually my requirement is like this:

    The user can take the photo using the inbuilt camera of the device.
    Then the user will open the application and browse to the stored image folder and want to display the phote taken.
    So when the user takes the photo using high resolution then the out if memory error is coming while display on the canvas.

    So As per our discussion if it is not possible to display larger resolution image in the canvas due to the low heap memory(2mb in Nokia Series 40 devices), I want to restrict to the creation of image if it is larger resolution and want to display a proper message to the user.
    I think now you got my actual requirement!


    So please guide me!!!

    Thanks & Regards,
    Ajit

  6. #6
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Out of memory error while calling the createImage()?

    Quote Originally Posted by ajitkumar26 View Post
    Hi Ekta,

    Actually my requirement is like this:

    The user can take the photo using the inbuilt camera of the device.
    Then the user will open the application and browse to the stored image folder and want to display the phote taken.
    So when the user takes the photo using high resolution then the out if memory error is coming while display on the canvas.

    So As per our discussion if it is not possible to display larger resolution image in the canvas due to the low heap memory(2mb in Nokia Series 40 devices), I want to restrict to the creation of image if it is larger resolution and want to display a proper message to the user.
    I think now you got my actual requirement!


    So please guide me!!!

    Thanks & Regards,
    Ajit
    The images taken by inbuilt camera are stored on the device with in JPEG file in EXIF Headers -- from hearers you can read the size of the image height x width -- if its more then 640x480 show the message or show preview thumbnail image -- reading the thumbnail from EXIF headers --- or show the Image outside the application passing the file path to platform request - not recommended - as you will need to exit the app and lose the control if the image is opened by the device outside your application.
    Thanks,
    Ekta

  7. #7
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Out of memory error while calling the createImage()?

    Thanks Ekta for your reply,

    I do not know how to read the size of the image height x width from EXIF Headers.
    So Please help me!
    Please provide me some code snnipet or some useful links which help me to solve my problem.
    Thanks & Regards,
    Ajit
    Last edited by ajitkumar26; 2010-06-24 at 12:28.

  8. #8
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Out of memory error while calling the createImage()?

    Quote Originally Posted by ajitkumar26 View Post
    Thanks Ekta for your reply,

    I do not know how to read the size of the image height x width from EXIF Headers.
    So Please help me!
    Please provide me some code snnipet or some useful links which help me to solve my problem.
    Thanks & Regards,
    Ajit
    For more Info on EXIF headers ---> Try http://gvsoft.homedns.org/exif/Exif-explanation.html

    Try this link for thumbnails from Headers: http://atif-razzaq.blogspot.com/2009...jpeg-exif.html
    Thanks,
    Ekta

  9. #9
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Out of memory error while calling the createImage()?

    Thanks Ekta,

    But I want to know that
    Is EXIF support in Nokia series 40 devices?
    Because what ever information I got from the forum about EXIF of an image is from Nokia series 60 devices.
    But I am developing the application for Nokia Series 40 devices.
    So please can any one tell me that
    Is EXIF support in Nokia series 40 devices?


    Thanks & Regards,
    Ajit
    Last edited by ajitkumar26; 2010-06-25 at 12:17.

  10. #10
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Out of memory error while calling the createImage()?

    Quote Originally Posted by ajitkumar26 View Post
    Thanks Ekta,

    But I want to know that
    Is EXIF support in Nokia series 40 devices?
    Because what ever information I got from the forum about EXIF of an image is from Nokia series 60 devices.
    But I am developing the application for Nokia Series 40 devices.
    So please can any one tell me that
    Is EXIF support in Nokia series 40 devices?


    Thanks & Regards,
    Ajit
    Please click a photo with your S40 device and open the JPG file generated by it and search EXIF headers in the byte data to see if exist or not. (I feel they should)
    Thanks,
    Ekta

  11. #11
    Registered User
    Join Date
    Nov 2009
    Posts
    188

    Re: Out of memory error while calling the createImage()?

    Thanks for your reply Ekta,

    I am developing the application using CLDC1.1 and MIDP2.0 for Nokia series 40 devices.

    I have tried a lot what you have told but in j2me I am not getting the proper api to check the exif header in the image byte data.
    Can you please post the code snippet for the same(Presence of EXIF header in the image byte data). It will help me a lot.

    Please help me...


    Thanks & Regards,
    Ajit

  12. #12
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Out of memory error while calling the createImage()?

    Quote Originally Posted by ajitkumar26 View Post
    Thanks for your reply Ekta,

    I am developing the application using CLDC1.1 and MIDP2.0 for Nokia series 40 devices.

    I have tried a lot what you have told but in j2me I am not getting the proper api to check the exif header in the image byte data.
    Can you please post the code snippet for the same(Presence of EXIF header in the image byte data). It will help me a lot.

    Please help me...


    Thanks & Regards,
    Ajit
    I have already posted the URL of example where we read Thumbnail from EXIF headers in j2me - http://atif-razzaq.blogspot.com/2009...jpeg-exif.html
    Try it.
    Thanks,
    Ekta

Similar Threads

  1. No memory error while using EzLib
    By strike_noir in forum Symbian
    Replies: 3
    Last Post: 2008-04-22, 12:54
  2. Image.CreateImage() hungry of memory!
    By kimi007 in forum Mobile Java General
    Replies: 2
    Last Post: 2007-01-11, 15:31
  3. error found while calling "bldmake bldfiles"
    By anand_zain76 in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2006-11-17, 17:30
  4. Why createImage(x, y) takes so small memory?
    By Creator3D in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2005-03-22, 16:07
  5. createImage leaks memory
    By mariusfahlbusch in forum Mobile Java General
    Replies: 20
    Last Post: 2005-02-07, 10:36

Posting Permissions

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