negush blog

Flash, ActionScript and stuff…

March-11-08

5005: Unknown error optimizing byte code

posted by admin

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.

The solution would be to turn off the Optimizer and then recompile. You can turn the Optimizer off from the Publish Settings dialog box, select Settings for the “ActionScript 3.0″ option and in that dialog box disable the “Reduce file size and increase performance” option. You can do this whenever you are working on a very large project and get this error message. In the rest of the cases, you should leave this option checked.

Another solution I’ve found on the web (didn’t test it) is to delete the .aso files generated by Flash (Control -> Delete ASO Files) .

  1. deadlock32 Said,

    thanks bud. I got this error the other day and I am sure I would have taken a ton of time figuring out the fix, but in less than 5 minutes I was able to turn off optimizer.

    I go this error when I finished writing a recursive function.

  2. RB Said,

    I tried looking for your e-mail but could not find it. I’m linking to this blog post.
    If this is not OK, then please let me know.

    Here are the details:
    http://flashvoodoo.blogspot.com/2008/02/errors-5003-5005.html

    uses:

    http://www.negush.net/blog/?p=13

    I had his post as a draft for a while and just posted tonight.

    Regards,
    rbrisita

    E-mail server: hotmail.com

  3. admin Said,

    Thank you RB for linking to my article.

    Sorry about the missing contact information, I totally forgot to mention it somewhere. I updated my Who am I page and left my email address at the bottom. Again, sorry for that.

  4. Tyler Said,

    Hey, I fixed this with a friends help by increasing java vm heap memory size. On Windows right click on my computer -> properties -> advanced -> environment vars -> then make a new var like this

    JAVA_TOOL_OPTIONS

    and its value

    -Xmx1024M

    then my project published with optimize byte code on. . . woot. . . .

  5. BMA Said,

    Hey Tyler!
    Thank you very much for pointing this out!!
    I’ve wasted ages of time in finding a solution for this annoying problem…

  6. admin Said,

    Thanks Tyler,

    I’ll also be looking to see if this will work for Mac OSX too.

  7. anna Said,

    Thank you! Wish I’d searched on this earlier – I have spent about 6 hours trawling through my code trying to work out which element was breaking it – turns out all I had to do was turn off the optimiser and delete the ASO files.
    And yes, it does work on Mac OSX! :D

  8. Clouds Said,

    Hi Tyler, thanks for pointing to this solution, but unfortunatly I was unable to fix this anoying problem.
    I’m using Flash CS4 here, when I add JAVA_TOOL_OPTIONS -Xmx1024M to environment vars, then I get the message: “Error initializing Java Runtime Environment. You may need to reinstall Flash.” every time I start a project in Flash CS4. How can I fix this?
    I got stuck in this problem for many days, I’ve tried to delete ASO files but there is no Optimiser option in Flash CS4 so it is totally useless here.
    Please help me!!!

  9. admin Said,

    @Clouds

    That’s a tough one. I’m still working in Flash CS3 so unfortunately I can’t help you with that. Maybe someone will come upon these comments and help us out on this one. I was hoping that they solved this problem in CS4, but it looks like it’s still there. Hope that there is a fix for this one in CS4.

  10. Zero Said,

    thanks for negush and Tyler. though problem still puzzles me. but i found headstream.
    thanks again.

    i’m a chinese,my english is not good, hoop it was supportability. :D

  11. kane Said,

    @Clouds
    You could change the value to -Xmx512M or lest untill you can work, this may be help~
    from china too`

  12. subin Said,

    I am still facing the “Error initializing JRE. You may need to reinstall Flash” error. I am using cs3 and i tried all the above mentioned tricks…. can any one help me… am a beginner in flash too…. please help m out

  13. admin Said,

    @subin

    This error is quite strange. I’ve been looking for it on the Internet but had problems finding any useful information about it. Certainly Adobe doesn’t mention it in it’s documentation.

    Maybe it has something to do with the JRE you have installed. Unfortunately I can’t help you on this matter. I’ve never come across this error message and I’ve been working with Flash CS3 on Windows XP and Mac OS X (never used Vista). You should try updating the JRE you have and let us know if you manage to solve the problem in any way. Thanks

  14. Cpt.Planet Said,

    So I’ve had this issue on our Project where we’ve reached a point we can’t add any more lines of code or new classes without getting this error, unless we start removing some. This is in CS4, in CS3 it’s not an issue yet (but I think after a bit it will have the exact same issue).
    “Reduce file size and increase performance” – Option isn’t in CS4
    “Delete ASO Files” – Didn’t work
    “Save and Compact” – Didn’t work
    “increasing java vm heap memory size” – WORKED!! (Thanks Tyler). But not with a value of 1024

    We’ve managed to get it to work with values of -Xmx128M and -Xmx256M.
    A value of -Xmx512M and higher we get the error “Error initializing JRE. You may need to reinstall Flash”. The machine being used has 2GB+ memory, I dunno if that’s an issue.

    I think the default for Flash is -Xmx64M as that value still gets the byte code error.

    I don’t know how much more code I can add before it fails again (maybe 4 times?). I can just only hope that Adobe sort this out soon.

  15. admin Said,

    Thank you Cpt. Planet. It really seems like changing the java vm memory setting is quite a good solution. I’ve looked around on the Internet and in AS2 there is a 32K limit to the bytecode on one frame but I couldn’t find out if this limit is still valid for AS3. Maybe this is why this error keeps annoying us.

  16. josefk Said,

    Great post and comments.
    Setting the ‘JAVA_TOOL_OPTIONS’ to -Xmx1024M also fixed the issue on my osx machine.
    It took a little while to figure out where exactly to set the variable (i am new to osx).
    What you need to do is:

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

    Add this to the file using a text editor:
    {
    “JAVA_TOOL_OPTIONS” = “-Xmx1024m”;
    }

    Log out/restart.

    Now the variable will be set every time you log in and you should be able to compile with the ‘Optimize bytecode’ on.

  17. admin Said,

    @josefk

    Thank you very much. Appreciate the info. I’m sure this would help a lot of people :)

  18. SubstanceMX Said,

    Well, for organize reasons I have 5 compiled apps inside one main flash. A lot of code for the first frame!

    Those compiled apps have an optimized code already, but compiling the main fla does again some optimizations.

    I express the gratitude for this tip, it worked under my app description. A minutes from the delivering for this proyect and that 5005 was close to crash and trash my work.

    Have a nice day.

  19. BadBoyBill Said,

    Thank you Tyler,

    After reading through this I solved the problem this way:

    1. Used Cpt.Planet advice, 1024M caused a flash error, “Error initializing JRE. You may need to reinstall Flash” 256M worked.

    2. At first it didnt work no matter what, I installed the latest JRE then it worked. And I also had to restart Flash CS3, didnt work until I restarted.

    Im not sure if it was due to the JRE or restarting flash.

    My project got very big, and started to get the 5003 error after adding anymore lines of code. Now I can continue with my project thanks to you.

  20. TomKat Said,

    Ok – I found a strange solution.

    If you are working on a large project with TONS of code and all of a sudden you get this error then start thinking.

    What did you do last? Start going backwards. Remove the code you created from the last time your app did publish and go from there.

    Sometimes flash tries to optimize code and its algorithm is not very good, so it runs into issues. Once you find what the error is, you will not believe your eyes. Your code will look perfect – no problem but for some reason flash is having tough time optimizing it. Well, the trick is to change stuff around in your code.

    Simply modify the order of execution, if you find that its an if statement, move the if to equal a Boolean and compare the boolean and things of this nature. The trick is to trick flash into optimizing it different than what it really is. Maybe put some dumb – not very useful variables in between, play around with it. You will get it to work eventually.

  21. admin Said,

    Thank you TomKat,

    that surely is a great help. However it should be done taking into consideration how readable is our code. But optimizing the code yourself before the optimizer is very well come.

  22. Macaca Said,

    @Tomkat: In a very large project this worked for us for some time, but soon even this trick wouldn’t work anymore.

    Our solution: we moved the code to a seperate SWF and compile this from FDT with Flex (as a Pure Actionscript project), and load all assets from a Flash IDE compiled SWF. FDT & Flexbuilder both allow you to specify the -Xmx parameter, and so far all seems to be ok. We did experience some issues with cross-SWF scripting etc, but that was to be expected (and are not serious show-stoppers).

  23. 5005: Unknown error optimizing byte code and “You cannot debug this SWF because it does not contain ActionScript” | flash cs Said,

    [...] me a while to find the solution that is why I am republishing. This fix was originally posted on negush Their post was originally about fixing the 5005: Unknown error optimizing byte code.  But what I [...]

  24. lique Said,

    thanks for this info,i had this problem (using cs4) about an hour ago,i googled ,and found this. i noticed the error,when i added an extra line of code to my 3d engine im working on. i tried the environment variable fix with 1024m, that didnt work,i did 512,that didnt work,but it worked with 256M like stated in a comment here. this could of possible drove me crazy ,so thanks!

  25. chaos86 Said,

    Thanks guys this is exactly what I’m looking for.
    Although I’m still having problems trying to set the ‘JAVA_TOOL_OPTIONS’ to -Xmx1024M.

    I’m using an Apple Mac osx and I don’t even know where to start.

    I read josefk’s comment but I have no idea how to find the folder or how to create a directory.
    As you can see I have no idea where to start.

    If anyone can write a step by step guide for someone using an osx that would be great.

    Any help would be great as I have a deadline coming up and all work has stopped :(

    Thanks

  26. admin Said,

    All you have to do is create a folder called .MacOSX and create a file inside it called environment.plist. Then, open up the file with a text editor and add the ‘JAVA_TOOL_OPTIONS’ variable (watch out – it’s gotta be an XML format). Just find some other .plist files on your system to use as an example.

    You’ll find more details here: http://mactip.blogspot.com/2004/04/setting-environment-variables.html, http://developer.apple.com/documentation/MacOSX/Conceptual/OSX_Technology_Overview/CommandLine/chapter_950_section_4.html and http://developer.apple.com/qa/qa2001/qa1067.html.

    Hope this helps ;)

  27. chaos86 Said,

    Thank you sooooo much for the speedy reply!

    Sorry where do I save the folder? Will it be in my user area along with the application, document, music etc folder?

    Just tried saving a folder called ‘.MacOSX’ and it’s telling me I cannot use the “.” symbol as it’s reserved for the system.

    I’ve also tried searching for this folder and it cannot find it.

    Sorry to be a pain but this is starting to get on my nerves.

    Thanks

  28. chaos86 Said,

    After half an hour trying to figure out how to add the the new folder and file I have now successfully done so…

    After restarting my computer I fired up Flash again with the hope of the problem being solved.

    Compiled it… and it came with with a new but very similar error

    5003: Unknown error generating byte code.

  29. Axe Said,

    I get the same error, i.e 5005 and the “you cannot debug this SWF because …..”. My fla is a big one with about already 10 videos embedded in it and this error comes only when I add a new page with radio buttons and it disappears when I remove this page. It is very weird.

    I tried what was told above, the environment vars thing, but it does not work. Also tried the Delete ASO files, but doesn’t work. Someone suggested a possible .swc files problem, but I wasn’t clear about that. Here is the post
    http://www.adobeshare.net/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=665&threadid=1369003&enterthread=y

    I am using a windows XP professional x64 SP2. I checked my adobe flashplayer version which is CS3 Professional and this is what I got.

    Player version : 9.0.124.0.
    Debug Player : NO

    I don’t have a Debug player, does it affect?

    I don’t know if it makes sense, but if I have 1 radiobutton in that page , I get no error, if I have 2 radio buttons,I get the 5003 error and if I have 3 radiobuttons, I get the ” you cannot debug this…. ” error.

    With the 1 radiobutton, it compiles correctly without error, when I select Control->Delete ASO files and test Movie. But when I try Debug-> Debug Movie for the same it doesn’t work. Strangely in both cases, the Publish file dos work. For other number of radiobuttons, neither of them work.

    I need this error removed as soon as possible, as it is putting to hold my work :(

    Can someone please help me :(.

  30. Axe Said,

    Whoaaa.. It just worked when I did this ….

    JAVA_TOOL_OPTIONS

    and its value

    -Xmx256M

    It didn’t work for 128M when I did it before, but it worked for 256M….. Sheesh .. so much for this …..

    I used to get either of these 2 errors : ” you cannot debug this SWF, because it does not contain ActionScript “. or the 5005/5003 error.

    Now it works, but I am sure it will come back again. i hope not. Actually as people here say, it has got to do with too much of code in a single fla file. try optimizing your code, but I am new to flash, so I guess I lack that.

    Anyways thanks a lot guys. This forum did really help and I hope ADOBE seriously does something about all these errors. It is very frustrating. !!!!

  31. admin Said,

    @chaos86

    The #5003 is kind of similar to #5005 so the same solutions would work for both of them.

    @Axe

    I’m glad you managed to make it work in the end.

    I’ve also had to deal with the #5003 and #5005 errors a few times due to the FlashEff or TxEff components (they introduce a lot of code in the .fla file) but I’ve noticed that an easy solution is to place each FlashEff or TxEff component instance into its own movie clip container, so they are not placed directly on the stage (the stage is not their direct parent). After this move, the errors seemed to go away. Maybe this would help you too.

  32. Axe Said,

    @ admin : hmm the problem came up today again, when I added more and more code, esp more radiobuttons. Increasing to -Xmx512M didn’t work and it’s giving me the Java runtime error, so I reverted back to 256M.

    So I am where I started yesterday, but with a lot more code in the fla, I was almost done and I knew it would come back, like I told yesterday. I need to get around this time and I dunno what to do. I am getting the “You cannot debug this SWF because it does not contain ActionScript” :( …sad !!!!

  33. Jesse Said,

    THANK YOU.

    I looked for a long time as to why this was happening with a project of mine and was completely stuck and ended up having to shrink my project to make it work after about 1000 trial and error attempts.

    I run CS4, and *Reduce file size and increase performance* wasn’t available for me either.

    What ended up working for me was modifying the java variable to -Xmx256M

  34. admin Said,

    I’m happy that this information helped you out.

    I have to thank all of you for contributing with valuable information to this article.

  35. Milan Orszagh (TheAustrianGuy) Said,

    Thanks alot for this blog entry and comments!

    CS4 with Vista here(3GB RAM), -Xmx128M worked for me.

  36. Carlos Said,

    Hi guys how do I do the JAVA_TOOL_OPTIONS bit? Where do I enter the stuff?

  37. Carlos Said,

    (by thing I meant “-Xmx128M)

  38. Axe Said,

    Hey guys I am back again. So as I said last time I used the -Xmx 256M and it worked.

    Now, I am trying to create an AIR application from the fla file which used the above the -Xmx 256M. It is not able to create an AIR application and is throwing up the error, ” Error creating AIR file. Picked up JAVA_TOOL_OPTIONS: -Xmx256M ” .

    The whole point in doing all the work I did above was to create an Adobe AIR installer, from the flash file, now that I get this error, it doesn’t solve my purpose at all and I am not sure what to do. I cannot remove the -Xmx 256M, as it is the only one which helps my .fla file run, but the AIR installer does not seem to like it.

    Anyone got any pointers on this ? :(

  39. admin Said,

    @Carlos

    Tyler (comment no.4) explains how to add the JAVA_TOOL_OPTIONS value for Windows and josefk (comment no.16) describes how to do it for Mac OSX.

    @Axe

    Thanks for getting back to us. Unfortunately I’ve never seen that error message and frankly to speak I don’t really see what exactly does the AIR installer have to do with the JAVA_TOOL_OPTION value. Sorry, but I can’t really help you out on this one. But if you come across a solution we’d be happy to hear about it :)

  40. Lahcania Said,

    Thanks for the great info! I was really worried when I first got this message, wouldn’t have had a clue what to do if it weren’t for this page :) -Xmx128 worked for a CS4 on vista, and I also had to restart flash before it started to work.

  41. Lahcania Said,

    Just had a problem where suddenly I started getting this error again, and I fiddled with JAVA_TOOL_OPTIONS value, changed it to something else and then back again (restarting flash both times), and I stopped getting the error message (for now, at least). Hope this helps anyone with the same problem.

  42. Liquidweaver Said,

    I have worked this out on Mac OS X (10.5.6):

    you have to add a value to the environment.plist:
    JAVA_TOOL_OPTIONS
    -Xmx1024

    if you don’t have this file, you can create it here:
    ~/.MacOSX/environment.plist
    where ~ is your home dir, and you may have to create both the directory and the file; please refer to Apple’s documentation on plist creation:
    http://developer.apple.com/qa/qa2001/qa1067.html

    You will need to log out and then back in for this to take affect…

    !!!AND!!!

    YOU CANNOT RUN FLASH FROM SPOTLIGHT

    For some reason, Spotlight ignores the environment.plist options; I’ve logged an issue with Apple regarding this shortcoming.

    Hope this helps!

  43. admin Said,

    @Lahcain and @Liquidweaver

    Thank you guys for all the info. I’m sure a lot of people will find it useful.

  44. chockablock Said,

    You guys save my life. Thanks a lot

  45. Stanislav Said,

    only uncheck “Reduce file size and increase performance” helped.
    Delete ASO Files – did not.
    JAVA_TOOL_OPTIONS – did not

    Adobe Flash CS3 Professianal:
    .fla size: 10.4 MB
    Number of Classes: 392
    Lines of code: 49044
    Symbols: 1 329 793

  46. Stanislav Said,

    ah, quality removing this options of embedded fonts is crap…

  47. Stanislav Said,

    1. set
    JAVA_TOOL_OPTIONS
    -Xmx256M

    2. File >> Save and Compact (fla goes to 5.17 MB)
    3. Close Flash,
    4. Open Flash

    Compile worked :) 10q all special 10X for @Tyler

  48. x3m-Group Blog » Blog Archive » 5005: Unknown error optimizing byte code - No Excuses! Said,

    [...] more about this error 5005: Unknown error optimizing byte code [...]

  49. Matt Said,

    @Tyler and everyone else: This just made my day!! The 256M fix also helps when trying to export SWC from Flash — I had already chopped down our large project into a bunch of smaller ones, but some larger files weren’t able to export the SWC along with the SWF anymore.

    Thanks for posting your solutions!

  50. Jeff Said,

    I ran into the 5003 error when I included a 40,000 line .as file in the first frame.

    Solved the problem by breaking the file into 20 smaller files and including each one on its own successive frame. This adds an extra 20 frame wait, but at 30fps, that’s imperceptible :)

  51. benjamin Said,

    HI !
    For those who have cs4, update to 10.0.2 should also fix the problem (at least on Mac)

  52. Notes & quotes » Blog Archive » 5005:Unknown error optimizing byte code… Said,

    [...] This little bad guy seemed to appear with flash cs3 and is still current with cs4. In fact it’s due to the amount of code generated when compiling and the java memory allowed to do that. Well you’d better read this and this. [...]

  53. CouldHll Said,

    set -Xmx32M…work on…cool..thank you..haha

  54. Josh Strike Said,

    Got this working on a really large project… the crazy thing is, I can compile it twice in a row, back to back without restarting or quitting the IDE, and have it throw this error the first time, and work the next. Without altering any code at all.

    The only explanation I can come up with for that is the JRE running into some bad blocks of RAM. I’m not convinced that code changes which seem to work temporarily are actually doing anything. It’s logical that upping the JRE’s memory would give you a better chance of avoiding the problem, but I’m becoming convinced that this is indicative of a hardware issue on the machine doing the compiling.

  55. admin Said,

    @Josh

    Hmmm… yours is an interesting approach and it could be true since in the case of large pieces of code, breaking it up into smaller ones does work. In this case I guess the problem would be either with the JRE’s memory management or maybe it’s an OS problem (though this happens in both Windows and Mac OS).

  56. Dennis Korf - Isioux Said,

    We were experiencing the same memory erros when producing our games.
    We kept rising the JAVA_TOOL_OPTIONS ..during the development.. pretty high too .. as the project grew to a fla of 385mb.

    If we set it to high i would get “Error initializing JRE. You may need to reinstall Flash” when opening the fla..

    I’ve just did a testcase.. and it seems we have a very simple solution to the JRE Error..
    Just open your Flash .. and before opening the project.fla .. open a new empty fla .. publish it.. and close it again .. then open your project.fla .. and NO problems with the JRE or Publishing!!

    Seems it reserves the memory or something when you first start of publishing an empty fla :-D
    Normally i had to restart Flash after every publish of the big project(with lots of tweaking the memory).. now i can just keep on publishing the big project!

    This was tested on a Vista 32 with Flash CS3.

    Like to hear if it works for anyone :)

    With kind regards,

    Dennis Korf
    Isioux

  57. admin Said,

    @Dennis Korf

    That’s quite an interesting solution you got there. Indeed, these memory problems are quite frustrating and I hope Adobe did manage to solve the issues (or some of them) with Flash CS4. Unfortunately I cannot confirm it for Flash CS4 since I didn’t have the chance to test it extensively (my main work is still done with Flash CS3).

    But I’m too interested to see if there’s anyone else conforming this solution for other platforms.

  58. Dennis Korf - Isioux Said,

    We are also mainly working with Cs3 .. but we did buy a cs4 edition to test if it had the memory problems resolved.. as a “solution” to the cs3 memory problems..
    We didn’t test the cs4 update that came out last week.. but we did test the one that came out before that.. that’s the fix that adobe claimed to fix the bug.. but it actually didn’t ..you wouldn’t get the error anymore or something.. but you would get the WSOD.. so that wasn’t a solution.

    Didn’t try the “empty publish workaround” with the cs4 yet.. but i’ll do some tests today.

    It seems that Flash holds on to the memory need of the first publish.. and works with that for every other publish while it’s open.

    Best Regards,

    Dennis Korf
    isioux.nl
    Youdagames.com

  59. Dennis Korf - Isioux Said,

    Tested the workaround on a:
    -vista 64 with cs3 : works aswell
    -Vista 64 with cs4(without the update fomr 2 weeks ago): doesn’t give an java or memory error.. so it doesn’t work there.. just a black screen

    Seems it only works for the JRE and “not enough memory” error..

    Dennis Korf
    Youdagames.com

  60. admin Said,

    @Dennis Korf

    Thanks for the valuable info. Benjamin said in a previous comment that the problem was solved with the new update for CS4 (10.0.2) at least for Mac. Maybe that goes for Windows too.

  61. Dennis Korf - Isioux Said,

    Nope.. collegue just tried the latest update of cs4.. no change in the publish effect.
    Actually.. since she did that update.. the cs3 is crashing alot :S .. not sure if it’s connected.. but it’s a big coincident.. :S

    Made a panel in jsfl ..

    var str = ‘fl.createDocument();’;
    str += ‘fl.getDocumentDOM().publish();’;
    str += ‘fl.getDocumentDOM().close();’;
    //str += ‘alert(“did publishclean”);’;
    MMExecute(str);

    If you make a panel from it.. and set the panel left of the properties panel..(so it has focus when you start flash) .. it publishes an empty swf when you start.

    Dennis
    Isioux

  62. admin Said,

    Thanks Dennis :)

    I’m sure this will be of help to all of us. Especially since I’m not sure Adobe can/will do something about the problem (at least for CS4).

  63. Dennis Korf - Isioux Said,

    the cs3 crashes mentioned earlier with the latest cs4 update is fixed by updating the cs3 to the latest version aswell..

  64. Luke Said,

    OK

    read all of thispage and still no concrete answer for a normal PC using CS3
    my error message is actually 5003: Unknown error optimizing byte code

    - tried reducing file size to increase performance which hasnt really worked that great – allowed me to put on layer on.

    - THEN tried this JAVA_TOOL_OPTIONS variable thing which i prob didnt wrong. am i supposed to find a file and stick some code in there ?

    this is turning into a bit of joke now considering i only really have 25layers to the slideshow on my timeline. Would have used the xml way had the timing not be so god dam crap and be different on different machines which effectively f*cked up the loop

    so can ANYONE, please point me in some kind of direction as to any other solutions ?

    will reducing my pictures in files size make a difference ?

  65. AndrewBoldman Said,

    Hi, cool post. I have been wondering about this topic,so thanks for writing.

  66. 5005エラー考 « Labs.Torques Said,

    [...] 5005: Unknown error optimizing byte code | negush blog [...]

  67. Dan Said,

    Thanks for this. Using Flash CS4 – increasing the Java VM heap memory limit worked a like a charm :)

  68. Tezcat Said,

    @ admin & all, thank you for adressing the topics you have in this post and the subsequent comment discussion, it seems Adobe has very little support for the JRE issue other than the CLASSPATH eVar one mentioned on their site.

    @ Dennis Korf, I am in your debt, your solution was the only thing that has resolved the issue for me, before I found this, I reinstalled flash CS3 3 times – as the error recommends, each time, the file would work fine for the first publish, but then it would appear again. Your work around explains why this phenomenon was occuring.

    I’m an solo indi Flash game developer, and I’m 5 months into a huge project (for me), when this seemingly unexplainable, unsolvable error cropped up. To be quite honest, it pushed me to near breaking point, Flash and AS3 are the only areas I am any way proficient in, due to it being affordable in both time delivery and resources I’ve sunk all my time into it, and now this was threatening to break my project and prevent me from finishing it, thinking it was my code or fla that was at fault, and not having any other avenues of development at my disposal I was at a BIG loose end, but now I know I can plough on, and the extra stress has gone! So Many thanks!

  69. Paul Musgrove Said,

    Just want to express a heartfelt thanks to all posters here. I stumbled on the bytecode error two days ago. Did some reading and fixed it by turning off the optimizer. That worked fine for a day, then, as my fla increased in size (to only about a half meg), got the missing swf message. Did some reading here, and set up JAVA_TOOL_OPTIONS as -Xmx256M. My problem has gone away.
    As I understand it, because I am not using my timeline at all (everything is in .as files), flash is loading the whole works into the first frame. That suggests to me that my former limit was probably 512K in the first frame and is now 256 meg. Can anyone tell me if that’s the case and this problem will not come back unless I exceed 256 meg in the first frame? (I’m about halfway through this project and all subsequent classes will be the same size, so the eventual size should be in the neighborhood of 1.5 meg or so.

  70. Paul Musgrove Said,

    Okay, so much for that theory. I just checked the size of another fla that WAS compiling with no problems, and it’s 2.8 meg (so far). So a 2.8 meg fla was working properly and a 500K one failed. ???

  71. admin Said,

    @Paul

    Hmm…. I’m not sure why that happened. This is a nasty bug. I hope one day we won’t have to spend hours trying to find a solution.

    Though I’m curious if this happens only in Flash Professional or Flex has the same problem too ?

  72. Dennis Korf - Isioux Said,

    @ Tezcat: Glad that it worked for you! :)

    The empty fla doesn’t work in every situation by the way.
    Although it does solve alot.

    I’m still having some problems now and then.. but that is that Flash makes my fla double the size after a save. Then it’s suddenly 360 instead of 180 mb. The strange thing is that it is small again if you do a “save as”.
    So if you’r suddenly having troubles with publishing.. compare your filesize with a backup version.. if it’s suddenly 2 times the size.. just do a “save as” and you can probably publish again.

    Hope the size bug is fixed soon aswell.. it’s been there for a while..and can reproduce it in CS3 and CS4(Latest builds)

    Dennis Korf

  73. Silverden Said,

    Hi all,

    Assuming this is a dead topic now – posting in july ‘09. Just wanted to post a thank you to tyler and others for the Java Memory fix. Setting to -Xmx32M worked fine for me – using cs4.

    I tried the empty.fla compile just previous to setting this environment var and it didn’t work, then tried it again after setting the var and it worked. Dunno if that is just coincidence.

    Had previously tried values from 128 to 1024M but no joy, so was delighted when the smaller value worked.

    Also, previous to this I had removed a CLASSPATH variable as suggested on Adobe’s site.

    Silverden

  74. admin Said,

    @Silverden

    It seems this topic is not dead at all. People keep running into this problem a lot.

    Anyway, I’m happy you found a solution among the comments.

  75. CouldHll’s Blog » Blog Archive » 奇怪的Flash bug Said,

    [...] 再然后,问题渐渐清楚了,可能是图片大小的问题。查看内存还有1G多,不可能资源不够。再到Google上结合图片资源等一查,找到了一个帖子:http://www.negush.net/blog/5005-unknown-error-optimizing-byte-code/comment-page-1/#comment-3573。在这个帖子的回复里找到叫JAVA_TOOL_OPTIONS的环境变量,心想可能有关,就胡乱改改吧,从-Xmx1024M改到-Xmx64M,不行,重启Flash才能测试效果,真是费时啊。直接改到-Xmx8M,不报错了,但是发布出来一片空白。。。唉,还是规矩点,改-Xmx32M,没想到成了,重新测试几次,没有问题,哈哈。。。终于。。。 [...]

  76. MichaellaS Said,

    tks for the effort you put in here I appreciate it!

  77. Wayne Said,

    More and more of this nonsense… a CS4 fla simply refused to publish giving the JRE error – even after I’d tried extending the JRE runtime memory to 256, 512, 1024… Switching it back to 64 (had been running at 128) did the trick. This is a little mad me reckons..!

  78. Chuck Said,

    Thanks so much for posting this. I never would have figured this out.

  79. ChrisH Said,

    Wayne,

    I just had the same thing happen to me. I’d previously had to increase the JRE runtime memory to 256 to get rid of the error, but recently it started happening again and the only thing that fixed it was switching it back to 64. Bizarre. Thanks for your comment, I would have never thought to try that solution otherwise, and thanks to everyone else who has shared tips here too. Now it’s just a matter of staying out of the path of black cats and making sure I avoid walking under ladders and opening umbrellas indoors until I get this project over the line.

    Also, I believe -Xmx368M is a valid value as well. Perhaps that will work for someone.

  80. Dennis Korf - Isioux Said,

    We had the same issue on windows Wayne.
    Especially with an xp pc using cs3.
    We’d turn it up till it gave some problems.. then we set it even higher.. this will work for a few times.. untill you hit the roof.. then you suddenly have to set lower values.

    At ChrisH: I believe every value you fill in will work. I’ve had times that it didn’t work with 255 .. but did work with 310. … or didn’t with 220 .. and did with 230. Don’t think it should be a “clean” memory number.

    With kind regards,

    Dennis
    Isioux

  81. Todd Said,

    Thank you all for all your input. I’m on OSX with CS4. By following 16, Josfk and 26, I was able to solve my 5005 error. Fantastic post! A lifesaver.

  82. China News » Blog Archive » flash反编译杂记 Said,

    [...] 发布项目时出现“5003: 生成字节代码时发生未知错误”。可以尝试的解决方法: 1、 在“文件->发布设置”的“ActionScript 3.0 设置”中不要勾选“减小文件大小并改善性能”(发布设置这个菜单项平时是没有的,必须打开项目的默认fla文件,一度又很纠结为什么在项目面板鼠标右键点击fla文件的时候不出现这个发布设置…); 2、 “控制->删除 ASO 文件”; 3、 增加一个系统环境变量 JAVA_TOOL_OPTIONS ,变量值设置为 -Xmx512M  (注意 512 这个数字需要根据情况调整,不同的电脑配置可设置的数值不一样,可以从 1024 开始往小里改。我的本本要改到 400 才行,大于 400 的数字会又一次导致’JAVA 运行时环境初始化出现错误’;修改了环境变量之后可以开一个命令行窗口输入命令 SET JAVA_TOOL_OPTIONS=ANYTHING 让新的环境变量立即生效,重新打开 Flash CS 程序即可)。 [...]

  83. trahm Said,

    The 5005 problem seems to have been finally solved by upgrading CS4 to 10.0.2 on mac as Benjamin said in an earlier post. This is one nasty bug that has made my life miserable over the last couple of weeks.

  84. Drake Said,

    Okay, after hours of desperation I solved the problem.

    My Computer Specifications:
    Windows XP, 86x Architect
    Using both CS4 and CS3 (don’t ask why)

    Steps:
    1) Open the environment variables from the advanced tab in System Properties.
    2) Click new under the System Variables and type in:
    Variable name: “JAVA_TOOL_OPTIONS” and Variable value: “-Xmx128M”
    3) If you have Flash open, save your work if you have to, then close it.
    4) As soon as you re-open your fla Flash document just open: File -> Save and compact
    5) Now test movie, it should work!

    * Note: If this doesn’t work just change Step 2’s “…128M…” to each one: 256M, 512M, 1024M.
    Good luck!

  85. Tompei Said,

    You can update Flash CS4 to 10.0.2 as well to solve this issue.

  86. 5005: Unknown error optimizing byte code « Mumbo Jumbo Said,

    [...] googling it, came across this thread 5005: Unknown error optimizing byte code on Negush Blog and even though it did help to some extent but the fact that my project was AIR based and this [...]

  87. Dennis Korf Said,

    @ Tompei: Updating to 10.0.2 on a Pc did nothing for me.

    Hope they fix this in CS5

  88. Vern Said,

    Thanks, thanks thanks! This post was a real time saver…Just to add to the anecdotes :
    I’m using CS4 on windows 7 with 8 gigs of ram . Despite all of my computer’s RAM, I had to go with -Xmx256M (higher values gave me the ‘reinstall flash’ message).

  89. Mike Said,

    Thanks much for help with this stupid error message. I apparently just hit it, would have thought the first 40k lines of actionscript would have been too much.

  90. Tompei Said,

    @Dennis Korf : True. This error is showing its nasty face once again now I’m trying to split my project in parts. (I know…)

    - Clear ASO : no effect.
    - JAVA_TOOL_OPTIONS trick : not working for me.
    - Upgrading : worked in some case.

    Flash debugger is too limited in such cases.

  91. Dennis Korf - Isioux Said,

    You could try and set your virtual memory extremly high aswell.

    I know it makes no sense.. as i have 8 gig normal memory.. but still, if you increase your virtual aswell you can raise the amount you fill into JAVA_TOOL_OPTIONS. On some computer we can raise it to 520!
    C: 12926 – 16989
    D: 10000 – 50000

    Further more.. make sure you set the visuals/skinning of your windows to as low quality as possible.
    Configuration screen / System / Advanced tab / “visual effects”

    With kind regards,

    Dennis Korf
    I Sioux
    YoudaGames.com

  92. Dennis Korf - Isioux Said,

    Ow, and don’t forget to do a clean/empty swf publish before you open anything else!
    Otherwise Flash will calculate it’s needed memory for publish wrong.. by adding any used memory in that session.

  93. admin Said,

    Thanks Dennis, this could also work.

Add A Comment