Flash Error 5003 & 5005
Tuesday, August 18th, 2009“5003: Unknown error generating bye code.”
“5005: Unknown error optimizing byte code”
You may find yourself receiving either of the above errors when working –in the Flash IDE– with FLA files that make use of large amounts of code. These two errors both stem from the same problem; Flash not handling an “Out Of Memory” error exception from Java (from the asc_authoring.jar file). This error will be apparent if compiling using the Flex SDK.
There are several possible solutions you can try to get around this error. Firstly, check that the Flash Optimiser in the Publish Settings dialog box is disabled (select Publish Settings and disable the “Reduce file size and increase performance” option under Script Settings), and recompile. In any other case where you are not getting a 5003 or 5005 error this option should be left enabled.
Another solution you can try, if disabling the Optimiser does not resolve the issue, is to delete the ASO files and recompile (Control -> Delete ASO Files and Test Movie).
Depending on the size of your project it is possible that these two solutions do not resolve the issue. If it is not possible to compile the project using the Flex SDK (which allows you to easily set the Java VM heap memory) you will need to set an environment variable on your system to increase the Java VM heap memory size. How you do this will depend on your system:
Windows:
Right click on My Computer -> Properties -> Advanced -> Environment Vars
Make a new var like this:
JAVA_TOOL_OPTIONS
and its value
-Xmx256M
Mac OS X:
Create the directory and file (if not already there) ‘Users/{your user}/.MacOSX/environment.plist’
Note: The folder will be hidden in finder unless you enabled the view of hidden folders.
The Easiest way to create/edit this file is by using RCEnvironment, which will handle the creation and management of the file for you.
Enter variable JAVA_TOOL_OPTIONS
and its value -Xmx256M
Now Logout/restart.
In our tests we were able to successfully compile with values of -Xmx128M and -Xmx256M. A value of -Xmx512M and higher gave the error “Error initializing JRE. You may need to reinstall Flash”. Your mileage may vary based upon your machine specifications, if you find yourself receiving this error simply reduce the amount of memory allocated to the Java VM heap and restart again. After following the above steps you should be able to compile your project once again with the Optimiser enabled.
N.B. YOU CANNOT RUN FLASH FROM SPOTLIGHT OR OTHER LAUNCHERS
For some reason, Spotlight ignores the environment.plist options. An issue has been logged with Apple regarding this, in the meantime be careful when launching Flash from Spotlight or other application launchers.