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:

JAVA_TOOL_OPTIONS

and add this value:

-Xmx1024M

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.

11 comments:

  Scott

December 8, 2009 3:51 PM

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. *:-]

  Shakespeare87

April 21, 2010 5:12 AM

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.......... ^ ^

  Txivi

June 15, 2010 10:45 AM

So much thank you dude, you saved our day

  Art

June 22, 2010 11:07 AM

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.

  Hadi

September 13, 2010 5:08 AM

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!!! :)

  Anonymous

October 7, 2010 7:16 AM

Hey,

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

Cheers,
ak

  Anonymous

January 31, 2011 10:36 AM

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

  Anonymous

March 13, 2011 5:18 AM

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

  Anonymous

April 5, 2011 7:53 AM

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.

  Steven

June 21, 2011 9:41 AM

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.

  Anonymous

August 2, 2011 9:16 AM

Danke für die Hinweise - ich hatte das gleich Problem mit CS5 und AS3. Ich haben dann über den Link http://mactip.blogspot.com/2004/04/setting-environment-variables.html 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!!!