You Are Here:

Community: Developer Discussion Boards

#1 Old Angry LWUIT jar size - 2009-02-17, 07:20

Join Date: Aug 2008
Posts: 197
Location: Sri Lanka, Colombo
Send a message via Skype™ to HasithaRandika
HasithaRandika
Offline
Regular Contributor
hi experts,

i'm in a helpless situation...
cz i have develop a application using LWUIT.
nw the application size is mre than 1Mb from that 1Mb 764Kb is for the LWUIT jar file.

so is there a way to reduce the LWUIT jar size.
if can't what will be the best option to build attractive GUI??????? (not MIDP)


regards,
Randika
Reply With Quote

#2 Old Re: LWUIT jar size - 2009-02-17, 08:33

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Quote:
Originally Posted by HasithaRandika View Post
hi experts,

i'm in a helpless situation...
cz i have develop a application using LWUIT.
nw the application size is mre than 1Mb from that 1Mb 764Kb is for the LWUIT jar file.

so is there a way to reduce the LWUIT jar size.
if can't what will be the best option to build attractive GUI??????? (not MIDP)


regards,
Randika
Hi,
Have you used obfuscater in your application...if no then please set the level of obfuscater as highest. This will reduce the size around 30%.

If yes,then you have to take care of the resources you are using..like images..media if any..other like text files..and so on..
You can use a compression tool for the image so that you can minimize the images in size..you can use pngout....it is a good tool,can be found on Google...
please tell us more about the application...


Thanks

R a j - The K e r n e l
Reply With Quote

#3 Old Red face Re: LWUIT jar size - 2009-02-17, 11:24

Join Date: Aug 2008
Posts: 197
Location: Sri Lanka, Colombo
Send a message via Skype™ to HasithaRandika
HasithaRandika
Offline
Regular Contributor
hi raj,

thanks for your advises i have done the obfuscater still the application size is arnd 918Kb.
most of the sis is occupied by the images folder.
dats wat i have found out????

regards,
Randika
Reply With Quote

#4 Old Re: LWUIT jar size - 2009-02-17, 11:28

Join Date: Apr 2007
Posts: 1,757
Tiger79's Avatar
Tiger79
Offline
Forum Nokia Champion
well then get started with cutting out all images u dont need :P
how big are those images (in pixels) ?
also have u tried out the utility raj2me is pointing out ?
also lwuit uses a proprietary system for compressing images, which also places all images into a single bigger one, more info about that is found in their manual...
Reply With Quote

#5 Old For Attaractive and fast development - 2009-02-17, 11:28

Join Date: Oct 2007
Posts: 21
sasikumar31
Offline
Registered User
My suggestion is J2ME Polish.
Reply With Quote

#6 Old Re: LWUIT jar size - 2009-02-17, 12:16

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Hi,
As Tiger suggested that start to cut the size of the images and rest of the other resources....

Can you please tell me that what kind of the application is this....leads this much of the jar size...How manu images and with what size you are using...
What exactly you are having in the res folder of your application...?
What is the code size?


Thanks

R a j - The K e r n e l
Reply With Quote

#7 Old Re: LWUIT jar size - 2009-02-17, 16:58

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
Make sure that there is only necessary files in your JAR file. Check whether there is any Junk/Temp files like Thumbs.db in your JAR. As others mentioned, try to reduce the picture's size.

Regards
Gopal


MobiQuil.com
An initiative by Developers for Developers.
http://www.mobiquil.com - Alpha - Launched.
Reply With Quote

#8 Old Re: LWUIT jar size - 2009-02-18, 05:08

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Hi,
Yeah,Bala is perfectly correct,check the same in the resources.If it there then delete the same..this file will be around the 70 KB....
However after deleting this..still the jar will be around 840 KB..again this will be a heavy one..please go and check the images and other resources...


Thanks

R a j - The K e r n e l
Reply With Quote

#9 Old Re: LWUIT jar size - 2009-02-18, 11:47

Join Date: Aug 2008
Posts: 197
Location: Sri Lanka, Colombo
Send a message via Skype™ to HasithaRandika
HasithaRandika
Offline
Regular Contributor
hi guys,

thanks for your replies,

i have reduce the image sizes nw the application size is around 400Kb.

but some times i'm getting outOfMemory Errors
is dat something to do with my coding or is it due to LWUIT

raj i'm developing a loyalty mobile application where customers can view points,vouchers etc

thankz,
guys
Reply With Quote

#10 Old Re: LWUIT jar size - 2009-02-18, 11:57

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
These things could be tried :

* Set the objects to null after using it(For eg: Image, Audio objects).
* Proper handling of Threads.
* Closing of RecordStore after using it.
* Minimise the heap memory used.
* Use Obfuscator
* Minimise the resource file size.

Also have a look at Java Performance Tuning

Regards
Gopal


MobiQuil.com
An initiative by Developers for Developers.
http://www.mobiquil.com - Alpha - Launched.
Reply With Quote

#11 Old Re: LWUIT jar size - 2009-02-18, 12:06

Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
Send a message via Skype™ to raj_J2ME
raj_J2ME's Avatar
raj_J2ME
Offline
Forum Nokia Champion
Quote:
Originally Posted by HasithaRandika View Post
hi guys,

thanks for your replies,

i have reduce the image sizes nw the application size is around 400Kb.

but some times i'm getting outOfMemory Errors
is dat something to do with my coding or is it due to LWUIT

raj i'm developing a loyalty mobile application where customers can view points,vouchers etc

thankz,
guys
Hey,
What I was planing in my mind to write,has already been write by Bala..so go and check the same .All thesee points I have followed and trust me are very much critical to get rid of the Out Of memory..

This is docs That I found and are as -
Quote:
There are several reasons for this. Memory consumption is one thing, there is some memory overhead every time you create a new object from a class and so forth. Speed is another, on the low level side of it, true object oriented java creates more bytecode opcode instructions and more instructions take a longer time to execute.

But the main issue is size. And it has more to do with java midlet packaging in jar files than the structure of java bytecode, really. Midlet jar-files are compressed using the zip deflate algorithm, and deflate compresses files individually. Two separate files always get better compressed if you join them to one file. Basically, this is because the deflate algorithm gets more data to work with. So if you think about this, your jar file will compress better if you gather your code into a few java class files instead of having your code spread out in lots of smaller class files. The approach to join data into bigger data pack files to get better compression can be used for your game data (images, level data etc) as well. More on this in the size optimization section.

So, two classes is basically what you need. One MIDlet class and one Canvas class. The canvas class can implement the Runnable interface so you can use it to run an update thread for your game animation.

Some other basic tips:

Use switch-case blocks instead of if-blocks as much as you can. Switch case blocks gets translated in to java bytecode jump tables when compiled that uses less instructions and runs faster. This is good for speed optimization, especially in your inner loops.

Access public variables directly instead of using get and set functions. This looks like bad programming, but it’s actually faster and uses less bytecode instructions.

Use local instead of global variables when you can. Using local variables is faster and uses less bytecode instructions.

Don’t forget to free memory by setting your objects to null when you don’t need them anymore. The garbage collector will take care of it when it gets a chance. If you want to be sure the garbage collector runs (after an initialization routine for example) you can always use the System.gc(); function to activate it.

Another very basic but still good tip is to always declare your constants to final static. The declarations are still going to be compiled into your java class file, but they get removed if you use a good bytecode optimizer such as Proguard
Please check that are these helpful to you?


Thanks

R a j - The K e r n e l
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Audio Input Stream on N80 tkaihock Symbian Media (Graphics & Sounds) 9 2006-06-30 10:15
OTA max jar size lewsterin Mobile Java General 4 2006-01-27 10:47
The correct meaning of MAX JAR size bigrio Mobile Java General 1 2004-11-16 11:30
The correct meaning of MAX JAR size bigrio Mobile Java General 0 2004-11-13 12:03
A Different Jar Size Limit Problem cicdem Mobile Java General 0 2004-06-17 16:01

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia