12 Replies Latest reply: Dec 10, 2012 10:09 AM by sinious RSS

    How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space

    rachalmers Community Member

      I'm trying to rebuild my iPhone app, with hires graphics etc, using CS6 Flash Pro. However, I get this now,

      Exception in thread "main" java.lang.OutOfMemoryError.java heap space .....  followed by a lot of location information related to the error.

       

      Now, how do I increase the java memory allowances if that's the problem. I've already upp the jvm.ini file from 128 to 512. No difference.

       

      I'm based on

      Win8, 8GB RAM, x64

       

      I'm obviously asking it to load a lot of resources - but hey, Flahs should be able to handle it right?

       

      thanks if anyone can help

        • 2. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
          sinious CommunityMVP

          Where is the location of that file and can you paste the exact lines you used for Xmx?

           

          For example (I'm using CS5.5) in:

          C:\Users\USERNAME\AppData\Local\Adobe\Flash CS5.5\en_US\Configuration\ActionScript 3.0\jvm.ini

           

          I set:

          -Djava.awt.headless=true

          -Xms128m

          -Xmx512m

           

          Flash starts just fine. I can reliably go up to Xmx640m but after that I sometimes see an issue starting Java.

          • 3. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
            rachalmers Community Member

            Hi, thanks,

             

            I set jvm.ini to this

             

            -Djava.awt.headless=true

            -Xms128m

            -Xmx2048m

             

            However, no success as yet. I have an icon file that is 1024x1024.png, and if I include that file as I am supposed to, I get the error. There are only 7.39MB of icon files in this build including that particular image - so I can't figure what the heck is happening?

             

            Maybe this error output will give someone a clue? Thanks guys

             

            java-error.jpg

            • 4. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
              rachalmers Community Member

              To the orginal reply... Just to let you know, this wasn't much help either. Similar problems, but no real solution. Thanks though, as every bit of knowledge on this helps.

               

              Message was edited by: Robert.A.Chalmers

              • 5. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                sinious CommunityMVP

                This is something unrelated (most likely) but 512 and 1024 Icon files should be left in the root build of your folder called "iTunesArtwork" and "iTunesArtwork@2x" respectively with them added in the XML:

                <icon>

                      ...smaller icons...

                     <image512x512>iTunesArtwork</image512x512>

                     <image1024x1024>iTunesArtwork@2x</image1024x1024>

                </icon>

                 

                They must be included in packaged files of course. Also you must now supply that 1024 PNG while submitting the app.

                 

                Aside that you can't use crazy numbers that exeed both Java nor the applications heap limitations. I've never needed to exceed mine beyond 512m. What kind of app file size are we talking about here?

                • 6. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                  rachalmers Community Member

                  Hmmm. Maybe I was doing something wrong with images, and icons. I'm not sure, as it's not at all clear really.

                   

                  This is the Icons screen from CS6, can't see the files above 512x512unless scrolling up - 29x29,57x57,114x114.  no matter.

                  So - after reading and rereading the Apple specs and directions, I removed the 512x512 and the 1024x1024 images from the Icons list that get pulled in during build.

                   

                  icons.jpg

                   

                  Next, I again re-read the Apple directives, and put the required files for the build into the base directory of the build, as per this image.

                   

                  BaseFiles.jpg

                   

                  In actual fact - I can probably leave out the last two. iTunesArtwork.xxx But I don't know, because it is entirely unclear on that point. I can find no directive regarding this at all.

                  Do I upload them myself? Probably? I don't know.

                   

                  HOWEVER.

                  The build now completes. Java, or something, was very confused about finding that file called 1024x1024.png in the build list, and would not do it.

                  Take it out of icons, built fine. Put it in the icons directory, and crash...

                   

                  Now - with the setup I am using, it all builds fine for ipad and iphone, in all resolutions.

                  I don't know what the problem is with what Java is seeing, but this fixes it it seems.

                   

                  Hope that helps anyone else.

                   

                  cheers

                  • 7. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                    rachalmers Community Member

                    @sinious

                     

                    Yep, finially I worked that out.... I had images where I thought they had to go - but changed them as per my post.

                     

                    and as it turned out - with the image 1024x1024 actually in the icons directory, java crashes every time. It doesn't worry about the 512x512 one. But I've taken it out anyway. Live and learn.

                     

                    as for the crazy java memory numbers - call that desperation :-) They are being set back even now.

                     

                    thanks for your help.

                    • 8. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                      sinious CommunityMVP

                      Note in my example I left the .PNG off the name of the iTunesArtwork examples. You should remove that on your filename as well as in the XML. CS6 may do this automatically for you but adt or Flash Builder won't so it's good to get into the practice of doing it correctly.

                       

                      Glad you got it worked out. Apple loves to change things up . If you're all set please mark the thread answered so we can filter unanswered. Good luck!

                      • 9. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                        rachalmers Community Member

                        Further to that bit about images in the icons list.

                         

                        If I add that to the xml file, then try to build - it complains about them being missing from /icons

                        even though they are there. and they can't be added to the icons list. So I don't know how you are supposed to add them, other than in the base dir of the package, in the Include list as I put them.

                         

                            <image512x512>iTunesArtwork</image512x512>

                            <image1024x1024>iTunesArtwork@2x.png</image1024x1024>

                        • 10. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                          sinious CommunityMVP

                          I include them in my base dir as I mentioned. All my other icons are in a subfolder.

                           

                          You still have .png on the file extension for iTunesArtwork@2x, remove that and make sure the filename itself on the file system doesn't have .png. That might be your snag if your XML file is looking for it without the .png extension (the correct way).

                           

                          During packaging check the files you're including and you should see those 2 files in your root being added.

                          • 11. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                            rachalmers Community Member

                            @sinious

                             

                            I tried doing as you suggest, but CS6 Flash complains about anyother combination other than what I have in the image.

                            It complains if I manually edit the xml file. It complains if I don't add the png suffix.

                             

                            but as I say - it is all working now with my current set up, and the Payload contains all the correctly names files, see image below this one. The app compiles fine, and runs on the iPhone no problems. So I'm guessing it's file locations that had it foxed - and now it's fixed.

                             

                            thanks for the help.

                             

                            BaseFiles.jpg

                             

                            payload.jpg

                            • 12. Re: How do I stop "Exception in thread "main" java.lang.OutOfMemoryError.java heap space
                              sinious CommunityMVP

                              Apple at it again, inventing new icons and obscure ways to add them . I think they do it just to torture Adobe with meaningless updates.

                               

                              Your XML file is generated every time you open publish properties in Flash Pro, which is mildly irritating. I got used to copying the XML file, using publish just to change something like add or remove included files or change my credentials or IPA output folder. Then I'd close it, you see it re-writes (pointlessly) the whole XML file. I'd then simply delete it and replace it with my previous XML file. I always found managing the settings in that file myself while avoiding the auto-generated Flash publish settings XML solved a lot of problems.

                               

                              All that matters is it works for you. If you're all set please mark the thread answered so we can filter unanswered questions. Good luck!