×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Create image memory usage

    Nokia memory usage, I am testing my application on a N91 with 64MB RAM, I am trying to open an image file 180k with my application, and I get a out of memory exception!? On an emulator I limit the memory to 8MB and open a file almost 1MB? What's with the memory usage on a N91?

  2. #2
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    I noticed that with the native image viewer can open images up to 900k but with my Java application I can open image less than 50k, why is Java 20 times less memory efficient? Is it possible to improve on the algorithm(I just use the standard createImage(InputStream is), what is the most efficient way of loading an image in Java?

  3. #3
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    I found that it has less to do with size in kb and more with the resolution I can open a 830k file with 1024x768 and not a file at 200k with 1280x1024! It's the Java decoding algorithm that's fault here!!!

  4. #4
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    Why when an N91 has 64M and unlimited heap size when I check with Runtime.gettotalMem it returns 819200 so a little less than 1M and ~360000 freeMem?

    Why is the memory for a single application limited to less than 1M?

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

    Re: Create image memory usage

    the memory usage is limited by the underlying KVM, and its limited constantly so if the app memory need keeps incrementing also the allocated memory will increment... this is all regulated by the KVM so as a user (or developer) you dont have any influence in it...

  6. #6
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    Hi,

    This clearly won't work in my case when I need to open a large image and my application hasn't 'warmed up' yet, so even if the memory capacity of the phone is 10M my application with go out of memory at 1M, how can I overcome this limitation, should I create a lot of 'garbage' objects and 'warm up' the virtual machine? That does not sound like a good execution style? Why doesn't the KVM allocate more memory when there is more available?

  7. #7
    Registered User
    Join Date
    Jan 2008
    Location
    Pune, India
    Posts
    4

    Re: Create image memory usage

    Hi,

    It's not just the size of the image file that matters. Its also color depth property of the target phone, besides the resolution.

    e.g. object size of the image on a phone having color depth of 12 pixels will be less than one having color depth of 16 pixels.

  8. #8
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    Hi,

    I am very grateful for All explanations, only how do I get around this? Is there any way, this is a critical issue for my application, without a solution the application is no more than a demo.

    BTW. How 'stupid' this is, a phone has 10M memory and the KVM will let me use only 1M even if the rest is free? There has to be some way of telling the KVM to freeup more memory?

  9. #9
    Regular Contributor
    Join Date
    May 2004
    Posts
    147

    Re: Create image memory usage

    Images loaded thru J2ME are stored in memory uncompressed, probably in the native display format. So a 1280x1024 24-bit image would take almost 4MB (or 5MB if it's stored as 32-bit).

    As for the memory available, I don't know. You managed to load a 1024x768 image but not 1280x1024, so you have a rough idea of the upper bound for the heap size. Maybe it can increase if you stop other software that is running in the background, or change some settings. (I'm not familiar with the phone or its supposed dynamic heap management.)

    But generally, J2ME applications aren't expected to use too much memory.

  10. #10
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    If You're right than this totaly defeats the use of compression like .jpeg and .png why even use compression if the 'shown' image will not get compressed. This seriously put my application in jeopardy if it's not possible to open all the images stored on a phone than the users won't be very happy about this and it won't be possible to Sell an application like this.

    So why does the native phone viewer have no problems with opening All images? This puts the use of Java seriously into question?

    Can You make a serious Java application(market ready) at All?

    If the execution and memory usage are 2-4 times greater than for native application than Java is not a viable platform for mobile.
    Although this cannot be correct since there are many Java applications on the market now? or is that just an ilussion?

    What is the ration between Java and native(C) applications on the market?

  11. #11
    Regular Contributor
    Join Date
    May 2004
    Posts
    147

    Re: Create image memory usage

    The idea of compression is for storage, not immediate use. That's true also for desktop software. Realtime compression is rarely used because loaded images are generally supposed to be ready for immediate use and direct pixel manipulation.

    If you want more control, then perhaps creating native code with C is what you're after. There are many uses for Java, and you can find creative solutions to many problems, but naturally it's more limited.

    I suppose the Nokia image viewer is a native piece of software with access to more resources and more fine-grained control.

  12. #12
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    I see, a thing like that would make my application dead or arrival.

    Isn't there a posibility of scaling the image or reducing it's resolution before it get's loaded?

    This is a make or break for this application unless I would limit it to phones with 64M+ memory which would include like 6 handsets now, and phones with more memory have higher resolution cameras so the problem is perpetual.

  13. #13
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    On a Sun Emulator 2.5.2 when opening images the memory usage does not depend on the resolution or even size on disk I found that images that are smaller in size and resolution can have a bigger memory footprint?! Weird, maybe it's just emulation or the images differ in some other way? Like one image that is 316k and 1024x768 takes 5M ram and a 1600x1200 and 600k takes 2M, that's a big negative difference, both are 24bit deep, not that it helps solve my problem yet.

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

    Re: Create image memory usage

    This is how I actually have been calculating the memory usage :

    I have an Image which is 1.5 times my screen :
    352 x 360 pixels = 126720 pixels
    This times 24 bits color depth = 3041280 bits
    This we divide by 8 bits = 380160 bytes
    This I divide by 1024 to get Kbytes : 371,25 Kbytes

    Anyways the memory footprint depends on the resolution and the bit depth, for those having an opposite result with the emulator : it's the emulator it is obvious that a higher resolution picture will need more memory than a lower resolution Image (with same bit depth)...
    Last edited by Tiger79; 2008-02-04 at 13:18.

  15. #15
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    63

    Re: Create image memory usage

    Hi,


    Anyone knows of an algorithm to resize an image from RAW data, so I can decrease the size before it gets fully decompressed?

Similar Threads

  1. Array memory usage
    By mcotten in forum Mobile Java General
    Replies: 7
    Last Post: 2008-01-04, 14:45
  2. Replies: 2
    Last Post: 2007-06-12, 13:00
  3. Saving an image to phone memory
    By dakz in forum Mobile Java General
    Replies: 6
    Last Post: 2007-04-12, 15:08
  4. Which tool soft do U use when create a png image?
    By riolg in forum Mobile Java General
    Replies: 1
    Last Post: 2003-03-26, 08:37

Posting Permissions

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