×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    2

    Nokia 6300, taking snapshot, out of memory exception

    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
    Join Date
    Mar 2006
    Posts
    516

    Re: Nokia 6300, taking snapshot, out of memory exception

    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
    Join Date
    Jun 2008
    Posts
    2

    Re: Nokia 6300, taking snapshot, out of memory exception

    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
    Join Date
    Mar 2003
    Location
    Barcelona, Spain
    Posts
    55

    Re: Nokia 6300, taking snapshot, out of memory exception

    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

Posting Permissions

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