Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User id212's Avatar
    Join Date
    Jun 2008
    Posts
    2
    We have an application that takes a snapshot and does a bit of processing with it then throws the image away. On Nokia 6300 it works fine for the first time, but any attempt to re-take a snapshot result in "out of memory" exception.

    The snapshot is taken at 640x480 and the application works without problems on other handsets (S60, SE).

    Any ideas?

    Thanks

  2. #2
    Super Contributor wang_shui's Avatar
    Join Date
    Mar 2006
    Posts
    516
    Hi,
    In s60 heap size of the devices will be unlimited but in the case of 6300 it is 2MB. So may be your image processing is taking more memory. I beleive you have to optmize the application to take less heap.

    Regards,
    WangShui

  3. #3
    Registered User id212's Avatar
    Join Date
    Jun 2008
    Posts
    2
    Quote Originally Posted by wang_shui View Post
    Hi,
    In s60 heap size of the devices will be unlimited but in the case of 6300 it is 2MB. So may be your image processing is taking more memory. I beleive you have to optmize the application to take less heap.
    Thanks for the quick reply. We are aware of the heap size limitations. The fact that the application works once is a good indicator that in principal the phone has adequate resources. What seem to be the problem that after processing the image once, the resources are not being released back or something similar.

    Any ideas what to check/how to optimize are appreciated.

    To clarify, the application works:

    1) start the Player:
    mPlayer = Manager.createPlayer("capture://video");
    mPlayer.realize();
    mPlayer.prefetch();
    mPlayer.start();
    and initialise the "viewfinder" in the Form control:

    mVideoControl = (VideoControl)mPlayer.getControl("VideoControl");
    mVideoItem = (Item) mVideoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);

    => the form is displayed with menu options at the bottom and active viewfinder through the camera

    2) take a snapshot
    The user presses "take snapshot" option and the image is captured:

    byte[] raw = raw = mVideoControl.getSnapshot("encoding=jpeg&width=480&height=640");

    3) create an image form raw bytes:

    import javax.microedition.lcdui.Image photo = Image.createImage(raw, 0, raw.length);

    4) process the image and then display again the "viewfinder" - a form with the running player

    to this point it works and it should just go to Step 2 and repeat from there (the previous image is no longer needed and should release the memory), however, instead taking a snapshot throws the "out of memory" exception and the application fails.

    I hope that some better management of the player object or using a Canvas object instead of the Form, or some other change can provide a workaround.

    Any ideas what to try?

  4. #4
    Regular Contributor rrafols's Avatar
    Join Date
    Mar 2003
    Location
    Barcelona, Spain
    Posts
    55
    Hi,

    As soon as you know that the user will take another snapshot you should clear the memory of the previous image and byte array. (also a call to System.gc() may help)

    If you do not clear those variables before setting them to the new value, you'll have both things in memory. The previous image marked for garbage collection and the new image.

    Also, as soon as you create the image from the byte array you should put the byte array to null if you don't need it anymore.

Similar Threads

  1. Infra-red capability
    By Symbian_Challenge_0412 in forum General Development Questions
    Replies: 1
    Last Post: 2005-08-16, 18:24
  2. Nokia PC Connectivity能否链接到cdma手机上发送短信和其他操作?
    By bborn in forum Web Technologies and Multimedia Content- Web 技术和多媒体内容
    Replies: 2
    Last Post: 2004-05-04, 11:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved