10 Replies Latest reply on Mar 31, 2011 4:58 AM by Peter Celuch

    Memory build-up in InDesign: how to free memory?

    Peter Celuch Level 4

      Hey guys,

       

      I'm fairly new to InDesign extendscript and quickly ran into a problem I can't solve for days.

       

      I'm working on flash panel (build with adobe extension builder) that among other things automatically exports page thumbnails, adds some data and so on.. while processing pages (real magazine with lots of content), the memory raises up to 1.5GB and InDesign crashes. When I try less pages and not crash InDesign, even after export script has completed, InDesign still uses some 1GB of memory.

      To initialy get page thumbnails, I use built-in function Document.fileExport (Menu -> Export (as JPEG)).

       

      The tricky part I absolutely don't understand is, that if I call it with options window (Document.fileExport: showingOptions = true), the memory instantly drops to about 10MB. So I "worked around" this issue by exporting pages in bursts (10 pages at time) and showing options for export of next 10 pages. This way memory builds up for 10 pages, then drops and builds up again. But never up to 1.5GB to crash InDesign.

       

      As you can guess, this workaround is real pain in the arse, because export is no longer automated and needs operator / monkey to push button every 5 minutes or so preventing InDesign crashing. (reminds me of TV series LOST )

       

      I tried calling $.gc() but absolutely nothing happened. Even when I created dedicated button with single purpose: call $.gc() and kept pushing it for 10 minutes after export was finished - nothing happened, memory was still up high.

        • 1. Re: Memory build-up in InDesign: how to free memory?
          Peter Celuch Level 4

          I truly wonder what is so special about Export-as-JPEG-Options-Window that it can instantly drop memory to minimum, even clearing cached page previews out of memory - 10MB is really low mem usage for and app and as I scroll the document and InDesign displays other pages, memory starts to build up again. When I show export options dialog, memory drops to 10MB and "forgets everything". It's really fun to observe how bizarre that is, but when I try to build a real flash panel and see that ONLY THING THAT CAN FREE INDESIGN MEMORY IS EXPORT DIALOG, it kind of makes me grab&pull my hair off.

          • 2. Re: Memory build-up in InDesign: how to free memory?
            Harbs. Level 6

            Please file a detailed bug report on this!

             

            The ARE memory build up issues in InDesign, and the more user cases the engineers have, the better!

             

            AFAIK, there's no way to get the memory usage back down (but what you write about the export window is very interesting). $.gc() only helps for pure Javascript objects.

             

            If you are working with the CS SDK (Extension Builder), one thing you can try is to create a pdf, and make the thumbnails from that using AIR features...

             

            HTH,

             

            Harbs

            1 person found this helpful
            • 3. Re: Memory build-up in InDesign: how to free memory?
              Peter Celuch Level 4

              Thanks Harbs, I just filed a report - I hope it'll help.

               

              The idea with PDF and AIR is interesting, I'll look into it. Albeit it won't solve my problem with memory buildup because the PDF export itself consumes the same ammount of memory as JPEG export.

               

              I wish there was a known way of releasing memory. InDesign has it and that's a fact: Export options dialog calls it. Adobe employees, isn't there some undocumented function that is called when a export options dialog pops up? Care to share it with us? It would really spare much hair on my head. And I like my hair

              • 4. Re: Memory build-up in InDesign: how to free memory?
                Peter Celuch Level 4

                Harbs, what did you mean by "make the thumbnails from PDF using AIR features"?

                HTMLLoader and BitmapData.draw()?

                 

                thanks

                • 5. Re: Memory build-up in InDesign: how to free memory?
                  Harbs. Level 6

                  Yes. That should probably do it. Make the container the resolution you need you thumbnails to be, and you should be good to go...

                   

                  (I haven't actually tried any of this, but it should work...)

                   

                  Harbs

                  1 person found this helpful
                  • 6. Re: Memory build-up in InDesign: how to free memory?
                    Peter Celuch Level 4

                    it didn't work. Standard HTML pages did well, but when I tried to draw() HTMLLoader with PDF content loaded, it captured only gray area (acrobat reader background, I guess).

                     

                    I'll try to post new thread about this with better title , hopefully some adobe guys will be able to give us some insight.

                    Once again, thanks Harbs for ideas and helping people!

                    • 7. Re: Memory build-up in InDesign: how to free memory?
                      Harbs. Level 6

                      A search for "open pdf in air" gets quite a few useful results.

                       

                      Here's one:

                       

                      http://ria.dzone.com/news/render-pdf-adobe-air-pdf

                       

                      Does this help? (I believe that you do need to have Acrobat 8 or higher installed.)

                       

                      Harbs

                      • 8. Re: Memory build-up in InDesign: how to free memory?
                        Peter Celuch Level 4

                        Thanks, but opening PDF was not the problem. I loaded and viewed PDF inside AIR application with few lines of code. The problem was that when I tried to capture pixels of the HTMLLoader object, it returned single-plain-colorer rectangle. When I loaded a HTML page instead of PDF, if worked fine - draw() returned expected result.

                         

                        The only explanation I can figure out is that it's something similar to trying to take a snapshot from a movie player. You get the desktop pixels and all, but the area where the movie was supposed to be is just plain black rectangle. I think the flashplayer just defines area where the PDF should appear and then "all the magic" happens outside the plashplayer, in separate "layer".

                         

                        So I think this way is busted - flash and AIR does not know what it displays (PDF), it only tells the operating system to show Acrobat reader in specific rect.

                        • 9. Re: Memory build-up in InDesign: how to free memory?
                          Harbs. Level 6

                          Interesting. Maybe you can get some better suggestions for extracting the images on one of the Flex/ActionScript forums.

                           

                          Another suggestion might be to open the pdf in Photoshop and create the thumbnails there...

                           

                          Harbs

                          • 10. Re: Memory build-up in InDesign: how to free memory?
                            Peter Celuch Level 4

                            I just reopened the old project (abandoned because of the memory build-ups) and was really surprised that it was suddenly working alright. I did a bit googling and found out that there's been an InDesign update in the August 2010 that included graphics export fixes.

                             

                            So if someone googled this thread, It's no longer relevant if you have ID update 2010/10.

                             

                            Way to go, Adobe!

                            Thanks, Peter