×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    May 2008
    Location
    Copenhagen, Denmark
    Posts
    84

    Image.createImage(..) gives OutOfMemoryError for 480x640 snapshot byte-arrays

    Okay, here we go again. Test phones are:
    • Nokia 3110 Classic
    • Nokia 5200
    • Nokia 6500 Classic

    Common for the phones are, that Runtime.totalMemory is 2.048 kb. Another common thing for them are that they're all capable of taking 480x640 pixel snapshots:
    Code:
    byte[] capturedImageBytes = videoControl.getSnapshot("encoding=jpeg&width=480&height=640");
    Unfortunately you can't decode this byte-array on the handset:
    Code:
    Image capturedImage = Image.createImage(capturedImageBytes, 0, capturedImageBytes.length);
    ... gives a java.lang.OutOfMemoryError. On the positive side, they can all handle the decoding of 240x320 snapshots.

    So ... is there some way of requesting a larger heap in the .jad file - or perhaps at runtime?

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Image.createImage(..) gives OutOfMemoryError for 480x640 snapshot byte-arrays

    Hi Steel_BRS,

    there's no way to alter Java heap, in any way.. what you could try to do (but you've probably already done it) is to free up some memory taken from some other resources (e.g.: other images, streams, etc...) in your app before trying to create the snapshot Image.

    Pit

  3. #3
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: Image.createImage(..) gives OutOfMemoryError for 480x640 snapshot byte-arrays

    Have you closed the camera player when you are decoding this byte array? If not, could you check that and report if the problem persists?

    Do you have any details on the memory usage before the decoding call? Like freeMemory?

    Hartti

  4. #4
    Regular Contributor
    Join Date
    May 2008
    Location
    Copenhagen, Denmark
    Posts
    84

    Re: Image.createImage(..) gives OutOfMemoryError for 480x640 snapshot byte-arrays

    Yes, I'm closing the player before Image.createImage(..)

    Runtime.freeMemory varies between 562 - 594 kb during the last 5 test runs.

  5. #5
    Regular Contributor
    Join Date
    May 2008
    Location
    Copenhagen, Denmark
    Posts
    84

    Re: Image.createImage(..) gives OutOfMemoryError for 480x640 snapshot byte-arrays

    During some memory optimization (incl. lazy-loading of icons, etc.) to make my midlet work on the Motorola RAZR V3i I accidentally also solved this problem.
    But you really have to be careful about how much you cache in memory.

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: Image.createImage(..) gives OutOfMemoryError for 480x640 snapshot byte-arrays

    Ok, thanks for reporting

    Hartti

  7. #7
    Regular Contributor
    Join Date
    May 2008
    Location
    Copenhagen, Denmark
    Posts
    84

    Post Re: Image.createImage(..) gives OutOfMemoryError for 480x640 snapshot byte-arrays

    Just to specify: after memory optimization I can take 480x640 pixel snapshots and call createImage(..) without getting an OutOfMemoryError. This is the case on ALL my current Nokia test-phones:
    • Nokia 3110 Classic
    • Nokia 5200
    • Nokia 6500 Classic

Similar Threads

  1. Preventing write-access to NFC tag
    By Jazz66 in forum Near Field Communication
    Replies: 4
    Last Post: 2009-06-25, 11:11
  2. Opening secure channel from the applet doesnot work with Nokia 6131
    By sujithkjoseph in forum Near Field Communication
    Replies: 0
    Last Post: 2008-06-05, 13:51
  3. what is an APDU
    By pawangjain in forum Near Field Communication
    Replies: 0
    Last Post: 2007-07-02, 07:42
  4. 有没有支持游戏外壳的模拟器啊
    By xian-dao in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 3
    Last Post: 2006-06-05, 03:54
  5. Loading images from byte array on 6130i
    By enlightment in forum Mobile Java General
    Replies: 2
    Last Post: 2002-06-05, 19:44

Posting Permissions

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