×

Discussion Board

Results 1 to 4 of 4

Thread: Heap question

  1. #1
    Regular Contributor
    Join Date
    Sep 2003
    Posts
    60

    Heap question

    I'm loading several Images at startup but after 90% of the images load fine the application then fails to load. The total size of the midlet is only 50kb so I assume it's a heap issue. I'm a new user to JBuilder and wanted to know if there's an easy way to find the heap size the application will require to run successfully.

    Thanks.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    United Kingdom
    Posts
    49
    I have a similar problem. I have an image that is 16x2880 pixels that I load, I then proceed to break up this image into 180 16x16 images. However the application fails at around 168 images. My problem appears to be running out of heap space, so I had to drop the max number of images that I was creating.

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Don't forget that when you load an image it will take [number of pixels]*[color depth in bytes]+[a little bit of everhead per image(constant)] bytes of heap space.
    Most of the Nokia color phones have 4096 colors, so:
    [color depth in bytes] = 2.
    Taking mrmop's example in a Series 40 device for example:
    16x2880 image ~ 90 KB
    180 16x16 images ~ 90 KB
    That's over 180 KB just for the images, and considering a Series 40 devices has around 200KB of heap, it's no wonder the app fails.
    Don't be fooled by the size of the png's. They are compressed and their size can be optimized a lot by limiting the number of colors used.
    On a side note, a 50K MIDlet is also compressed, and when the classes are loaded they are uncompressed so that's also something to take into account.

    shmoove

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    And to answer the original question:
    When you run the Nokia emulators you can specify a -heapsize parameter to take into account the size of the heap on the actual device. And there is also the status window (Tools-Status Window) that shows you the heap usage at runtime.

    shmoove

Posting Permissions

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