BlackBerry Programming Tip: Limit COD File Sizes to 64K or Less

RIM will tell you that a COD file can be up to 128K in size. Or, more precisely, contain up to 64K of executable code and 64K of data. Experience tells me otherwise, however, at least for applications that are installed using over-the-air (OTA) download.

If you’re creating an OTA application, make sure that each module in your application does not exceed 64K (65535 bytes) in size. If you don’t, the application may misbehave on certain models. The symptom is that a JVM error occurs when the application runs, requiring the user to reboot the device. Rebooting a device is never acceptable, and certainly not something you’d expect from a Java application.

So if your BlackBerry application is mysteriously crashing the Java VM on certain device models, look carefully at the size of the COD files. If any of them are greater than 64K, move code and data into other modules (create new ones if necessary) until all the modules are less than 64K. The crashes will probably disappear.

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • De.lirio.us
  • digg
  • Furl
  • Reddit
  • TailRank
  • YahooMyWeb

10 Responses to “BlackBerry Programming Tip: Limit COD File Sizes to 64K or Less”

  1. When you say “modules” you mean the different files “.cod” within the main file “.cod” ?

    I’m trying to port several games, and my games work in BlackBerry but they work very slowly, it could be because of my “.cod” within the main “.cod” are greater than 64kb. could you help me?

  2. A module generally corresponds to a .cod file, yes, although there are .cod files that are actually zips of other .cod files.

    In any case, the size of module won’t be affecting the speed of your game. It’s probably just the device itself. Remember that most BlackBerrys are clocked down to save on battery consumption.

  3. Thank very much!!! i really appreciate your answer,

    My game doesn’t seem to be painted well, it’s like it is painted sppliting by areas

  4. Karl G. Kowalski on May 14th, 2008 at 10:21 am

    I have developed and am currently in the middle of developing a large application for BlackBerry (up to 3 CODs and counting). We have not noticed mysterious JVM crashes as a result of OTA downloads….yet. Thanks for the suggestion, and I will make sure my QA team looks into this.

    The only issue I’ve noticed with OTA + Large COD Files is that using the “vanilla” BlackBerry browser will successfully download and install a large (> 64 KB) COD file, whereas using the service provider’s (e.g., AT&T, Verizon, Sprint, etc.) browser the download will fail, consistently. The download seems to fill the progress bar at the same rate, but just when it’s supposed to be completed, the “Application failed to download” message is displayed. RIM’s response has been: Tell your customers to use the BlackBerry browser.

  5. .cod files are zips of other .cod files. A module generally corresponds to a .cod file. Can , I manage the distribution of these sibling .cod files. For the better understanding, the size and couunt of sibling .cod files.

  6. Not sure exactly what you’re asking, Ravi…

  7. Hi Eric, Thank very much for prompt response.
    Actually, my .cod file is unzipped into 20 sibling .cod files. All are less than 64 KB in size. As, the size limit for the .cod files are 128KB. can, I reduce the no of sibling .cod files by increasiong their size??

  8. I wouldn’t try to make any of my .cod files bigger than 64K, as you’ll run into problems. You won’t be able to download the files over the air on all networks. And some people report strange and random behaviors when cod files exceed 64K. These two facts together make it important to keep them small….

  9. Hi, my main .cod file size is more than 64K and when i unzip this .cod file unzip this .cod file into 4 .cod files (like: .cod, .cod-1, .cod-2, cod-3) these all files are less than 64K - now issue is that when i download this application Over the air it shows me application downloade successfully and after that whenever i execuate my applicaton (in BlackBerry 7100 device model) it shows me error message “module .cod-3 not found”. Any help and comment on this would be appriciated.

  10. Hi,
    I have 2 questions:
    1) Using the JDE, it creates a .COD with two .cod files in it: one is 77780 bytes and the other is 23632 bytes. How do I shrink the first one?
    2) When I rezip the files, the size shrinks since the .COD was only storing them. Can I use the new compressed file in place of the original?

Leave a Reply