×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    57

    why throws this exception:ALERT: Maximum byte code length (32kB) exceeded

    Dear sir, I used Series 60 SDK with Jbuilder5 to run one of my MIDlet, but throws this exception on console window :
    ALERT: Maximum byte code length (32kB) exceeded
    why? by the way , my Jar file is about 300k.How can i solve this problem? I am anxious to reply. Thanks in advance!
    Dennis
    dennis

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    229

    RE: why throws this exception:ALERT: Maximum byte code length (32kB) exceeded

    Probably because you have a class file that's bigger than 32k?

    You need to optimise your code for size. Here are some tips, but if you search this forum and the J2ME related ones you should find some more comprehensive tips.

    1) Use a code obfuscator/compressor, something like JODE or RetroGuard. This will reduce the size of your class files for you.
    2) Learn what code constructs in Java take up lots of class file space. Static strings and static arrays are 2 big size culprits. Always place all the data you can into seperate resource files and load the strings and arrays up at runtime.
    3) If you're targeting a Nokia phone specifically (like the 7650), look at using the Nokia UI DirectGraphics class for images. This way you can store your image data in a raw format that gets compressed in the jar file, rather than PNGs which are not very well compressed.
    4) Reduce the overall number of files in your jar file. Each one add overhead to the zip file structure.

    Hope this helps,

    Steve

  3. #3
    Registered User
    Join Date
    Feb 2004
    Posts
    11

    I have similar problem

    Hi there,
    Like Dennis, my application also gives me the same problem when I run it on S60 Nokia emulator. Steve pointed that it is because class files exceed 32kb. But I have 9 class file and 3 of them were already much more than 32kb(almost double) couple of weeks ago and it was still working. But this morning I made some new adjustments to one file of my application(just code no image added or anything else to resources) and I started to get this error message. My total application is about 200kb(obfuscated).
    Is there any specific reason for this error and how can I track which parts are consuming this byte code. I will be glad if any of you guys can tell us something about this problem.
    Regards
    Serdar

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    26
    The 32kB limit is with method code, not with class file size. That is also why obfuscator probably doesn't help you here...

    Your classes sound very large to me, I suppose you are doing lots of initialized data or something similar. This is not a good idea size-wise, because even a simple int[] a={1,2,3} is turned into sequence of instructions by the compiler (you can use javap to view the instructions of your class).

    I suggest that you move your data into external resources in .jar file, it will also compress much better

  5. #5
    Registered User
    Join Date
    Sep 2005
    Location
    Bulgaria
    Posts
    6

    Re: why throws this exception:ALERT: Maximum byte code length (32kB) exceeded

    Thank you for your posts, they helped me much.

    I had this problem with arrays. If I add array to my class then emulator crashes with this message. I removed an array and it run. But I had enourmas (above 3000 lines) class (bacause I should save space).
    If you have such problem be very carefull with last changes . Any limit is exceeded (metod length, size of arrays ,etc). I just exctracted my arrays and now i'm loading them from data files.

    goog luck,
    Stoian
    Last edited by osoitza; 2007-04-16 at 12:26.

Posting Permissions

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