views:

454

answers:

4

The RIM compiler performs extra optimization and compression on the resulting ".jar" while building the final .cod file, but there are things that can be done by the developer to significantly reduce the final .cod file size.

One such thing would be to run PNGCrush, OptiPNG, or a similar tool to reduce the size of the included .png files. In an application with a large number of image files (such as an app featuring a custom UI), this can yield a significant reduction in the final .cod file size.

Do you have any tips for optimizing the final .cod file for size? Something to be done in the .java code itself? Something to be done in the project structure? Something to be done to the files or resources?

Thanks!

+2  A: 

Good question!

  • Compression (GZip, ZLib) may be useful when installing large bin/txt/xml files

And that's what they say in RIM:

Also, interesting facts:

All images was PNG format. I want to know why : compile with JDE 4.5 --> 900k, compile JDE 4.2, 2.6.1, 4.7 --> 1800k. What is difference ? Thanks !


Seems that JDE 4.5 uses more optimization techniques than older JDE versions.


Check the image below, it produced by PngOut from 55 K png image. It's size is 3427 bytes

Max Gontar
+2  A: 

I think you most certainly want to consider a shrinker (and optimizer/obfusticator) like ProGuard (http://sourceforge.net/projects/proguard/). This can shrink your Java code by collapsing full class names into shortened versions, removing unused code, etc. Along the way it can improve the efficiency of the code. It's great. The only hard part is modifying your build to optimize the generated class files before the RIM build stuff gets its hands on it to make a .cod.

Sean Owen
RIM already uses it's own obfusticator.
Henrik P. Hessel
+1  A: 

Hello,

A good approach is to GZIP all resources and then use net.rim.device.api.compress.GZIPInputStream class to load compressed files. That way you don't have to implement decompress code by yourself.

Also you can use pngout for optimizing image resources.

Lucas S.
+1  A: 

Make sure that you use PNG-8 instead of PNG-24 when possible. Try to minimize number of colors in palette. After this, use PngOut.

As for ProGuard, I have problems on old BB devices when using optimize feachure of Progruard ("-dontoptimize" switch) - so use it carefully, although it is a great tool.

Pavel Alexeev