Wednesday, April 8, 2009

5005: Unknown Error optimizing byte code

Recently I had a strange output error message in Flash CS4.
"5005: Unknown Error optimizing byte code"

After I did some research I found the Adobe answer:
"Extremely large Flash applications may compile incorrectly (Flash CS3, Flash CS4 Professional)"
read more:

My flash file wasn't so big (FLA file - 2Mb and the exported SWF file - 193kb).

I was using some Jumpeye components, so I was thinking they may be adding some extra code.
Jumpeye have posted very useful article about this problem:
"This is a really “interesting” error message that Flash throws in the Output panel and unfortunately there is no other explanation accompanying the message. At Jumpeye we’ve had to deal a few times with this error message which seems to be generated whenever working with large .fla files that make use of rather large amounts of code."

read more:

This posting describes different solutions. It took me some time to figure out which one works and which one doesn't. To help save your time, I decided to summarize both - the solutions and the results.

1. Uncheck “Reduce file size and increase performance” in Publish Settings/ Actionscript3 settings - unfortunately it is only in CS3 but not in CS4.
2. Control / “Delete ASO Files” - Didn’t work
3. File / “Save and Compact” - Didn’t work
4. “Increase java VM heap memory size” - WORKED!!!

To do that in Windows: right click on my computer -> properties -> advanced -> environment variables -> make a new variable:


and add this value:


Then log out or restart.

There was an issue when I opened Flash CS4 after the restart. I got the message:
“Error initializing Java Runtime Environment. You may need to reinstall Flash.”
I had to change the value from -Xmx1024M to -Xmx256M (or -Xmx128M). A value of -Xmx512M and higher causes every time the error “Error initializing JRE. You may need to reinstall Flash”.

After I set up the variable "JAVA_TOOL_OPTIONS" with value "-Xmx256M" everything started working fine.

For MAC users please look here:

I hope you'll find this post helpful.


  1. Thanks for finding this. I've been getting the error every time I publish, and it was driving me nuts.
    I took a guess for your option number 1, and in CS4, under File->Publish Settings->Flash, in the SWF Settings, turned off Compress movie. It seemed to work fine for me.

    Your foreground text is almost painful to read. You've got great content - make it dark enough to read. *:-]

  2. THANK YOU....................!!!!!!!!!!!!!!!!!!!
    YOU ARE MY SAVIOUR........................

    My Project turned up to be asset wise hard core and these funny stuff starts to pop up............
    OMG... It works..... 256 for one pc and 128 for another... It is all due to the specs of the computer.............

    THANK YOU AGAIN MY FRIEND.......... ^ ^

  3. So much thank you dude, you saved our day

  4. All attempts failed setting JAVA_TOOL_OPTIONS to –Xmx256M (or –Xmx128M or –Xmx512M or –Xmx1024M) yields an Adobe Flash CS4 error when publishing: Error creating AIR file. Picked up JAVA_TOOL_Options: -Xmx256M

    Running on a Windows 7 machine with the latest JVM. Still hoping Adobe will address the problem.

  5. just wanted to thank you. the client would have killed me if I had to tell him I needed more time to break my 20MB fla to smaller parts!!! :)

  6. Hey,

    Thanks for the tip...
    System variable addition solved this problem(with Flash CS4 & win7 x64)


  7. Flash CS5
    under users\(name)\AppData\Local\Adobe\Flash CS5\(language)\Configuration\ActionScript3.0\jvm.ini

  8. The above example for CS5 worked for
    me. what a rediculous error.

  9. Yep, changing to 256 there users\(name)\AppData\Local\Adobe\Flash CS5\(language)\Configuration\ActionScript3.0\jvm.ini really works for CS5.

    Thanks everyone for the help.

  10. Thanks for this post, it saved me from pulling out my hair any further.

    Interestingly enough, for this CS4 file I was publishing, it would say that there was 1 compile error, but did not display any message about what that error was. It was only by running the output SWF file (which was noticeably smaller than usual) that I got errors and knew something funny was going on.

    These were the errors I was receiving:

    ReferenceError: Error #1065: Variable Button is not defined.

    ReferenceError: Error #1065: Variable ComponentShim is not defined.

  11. Danke für die Hinweise - ich hatte das gleich Problem mit CS5 und AS3. Ich haben dann über den Link eine eigene environment.plist erstellt und dort JAVA_TOOL_OPTIONS auf den Wert -Xmx256M eingestellt. Danach wer der 5005-Error verschwunden und alles hat wieder normal funktioniert. Ein Neustart meines Rechners war nicht erforderlich. Super!!!

  12. Tried all of these suggestions, and it still isn't working for me.

    I am trying to load 600+ variables from an xml file.

  13. Thank you......You save my time.....Thank you again....!!!

  14. Thanks man, this is still useful 4 years later.

  15. In my case, I had to rename a class form Controls to DebugControls.
    No reason. No conflicts with other names. Not sure why.

    Try to isolate what is exactly giving you the problem (for me it was instantiating that class).

    Once you have isolated the problem, rename the class file and use the one with the new name. It will work again.

    If all of this doesn't work, buy a live chicken, cut it's head, and spread it's blood on the keyboard. This will unleash Voodoo developers' allies.