×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    3

    OutOfMemory Error from Image.createImage() After getsnapshot

    Hello. I'm developing a camera application for nokia 6700 classic model.

    I am using a generic method to get snapshot and image buffer as like this article (http://wiki.forum.nokia.com/index.ph...ic_using_MMAPI)

    But when i call createImage function, OutOfMemory error occured. Because the application was worked well in other j2me phones (nokia, sony .. ), I think there is no logical mistake in my source.

    I think this error occured because of too large snapshot buffer.
    I measured size of snapshot buffer using the following method.

    myImg = Image.createImage(jpgImg, 0, jpgImg.length);
    jpgImg = midlet.cameraCanvas.videoControl.getSnapshot(null);

    The size of snapshot buffer is about 35kbytes. I expect that the resolution of the image is 640*480.
    And available memory which measured from

    Runtime runt=Runtime.getRuntime();
    long freeMemory = runt.freeMemory();

    is about 150kbytes. I think because 640*480 image require at least 640*480*3 = 921.6kbytes of memory, OutOfMemory error occured.

    But i don't need the high resolution image like that. Even gray scale image of 160*120 size is enough for me. Actually, i have to do image processing on my image, to get raw buffer of small and gray scaled image directly is best for me.

    So i tried to contol resolution of snapshot size like this,

    jpgImg = midlet.cameraCanvas.videoControl.getSnapshot("encoding=jpeg&width=160&height=120");

    but the size of snapshot buffer is still same. And "encoding=gray8" nor "encoding=rgb&colors=rgb888" is also worked.

    Is there anyone who knows how to control the size of snapshot image?
    If it is not available, to know how to get enough memory for using Image.createImage() for 640*480 image is also helpful for me. (I cannot believe there is available memory is only 150k even i spend some memory for other resource)

    Thanks.

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: OutOfMemory Error from Image.createImage() After getsnapshot

    you also should always use garbage collect before doing a memory measurement...
    Even though it's not very precise...
    But yes, the 6700 classic has 2 megs of java heap size, so having a 970kb Image and maybe even having some other inmemory copy of that Image (or it's data) might get an OutOfMemory Exception...

    Personally I have no experience regaridng snapshots or even pictures... Even though (and I might be mistaken here) I though I read somewhere that the resolution with snapshots was kinda fixed ?

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    3

    Re: OutOfMemory Error from Image.createImage() After getsnapshot

    Of cource, I used System.gc() before i tried to make Image Object (Image.createImage())
    But it is strange that before i tried to make Image Object (it will require memory larger than 920kB) there is only 150kB available heap memory.
    Is it possible that the size of available memory in apps can be differ by user option or distribution method? I cannot find the user option for it. And i distributed my apps by copying jar and jad to external memory using MS explorer.

    To control the snapshot size, I refered to javame reference (http://java.sun.com/javame/reference/apis/jsr135/). But it did not work.

  4. #4
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: OutOfMemory Error from Image.createImage() After getsnapshot

    maybe you can find a more Nokia-specific solution on the Wiki ?

Similar Threads

  1. getSnapshot and N96
    By Steve29 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2009-04-09, 11:09
  2. jsr135 highest supported camera resolutions for getSnapShot() on N95
    By garyjamessilva in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2007-05-30, 21:14
  3. JSR-135 getSnapshot on Nokia 6102i
    By davidmanpearl in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-07-24, 21:12
  4. Nokia 6630 OutOfMemory problem
    By helenagin2 in forum Mobile Java General
    Replies: 4
    Last Post: 2005-06-30, 16:37
  5. getSnapshot doesn't work with WTK2.2
    By davidgu in forum Mobile Java General
    Replies: 0
    Last Post: 2005-03-11, 22:47

Posting Permissions

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