4 Replies Latest reply: Oct 12, 2010 1:43 PM by andrejusc RSS

    AVConversionConvertFromPDFWithHandler for jpeg memory leak?

    andrejusc Community Member

      Hi,

       

      I'm trying to utilize this AVConversionConvertFromPDFWithHandler call in my plugin to convert single page PDF into JPEG file. I've added available memory trace before and after this call and I have this data (in bytes here):

       

      2010.10.12 23:24:07:515 pid: 5612, tid: 7080: Memory before AVConversionConvertFromPDFWithHandler: 1038352384

      2010.10.12 23:24:12:546 pid: 5612, tid: 7080: Memory after AVConversionConvertFromPDFWithHandler: 1028227072

       

      So, you could see that AVConversionConvertFromPDFWithHandler ate about 10 MB of memory.

       

      My test PDF is 22 KB in size and generated JPEG is 387 KB. Why do we have such huge memory consumption? Do I need to call some special cleanup after that call is done?

       

      The version of Adobe ImageConversion.api plugin, which is involved in that conversion is 9.3.3.177. I'm running that on Windows XP.

        • 1. Re: AVConversionConvertFromPDFWithHandler for jpeg memory leak?
          lrosenth Adobe Employee

          If you make the call twice in the row, does the memory grow that much each time?  I suspect not.

           

          The first time you invoke it, it has to initialize itself and load all the necessary things into memory - but it's a one time thing.

          • 2. Re: AVConversionConvertFromPDFWithHandler for jpeg memory leak?
            andrejusc Community Member

            Memory grows each time with that call. Look at this:

             

            2010.10.13 00:13:51:109 pid: 6352, tid: 6596: Memory before AVConversionConvertFromPDFWithHandler: 1035579392

            2010.10.13 00:13:56:468 pid: 6352, tid: 6596: Memory after AVConversionConvertFromPDFWithHandler: 1025404928

             

            2010.10.13 00:14:45:968 pid: 6352, tid: 6596: Memory before AVConversionConvertFromPDFWithHandler: 990334976

            2010.10.13 00:14:51:515 pid: 6352, tid: 6596: Memory after AVConversionConvertFromPDFWithHandler: 988655616

             

            2010.10.13 00:15:45:374 pid: 6352, tid: 6596: Memory before AVConversionConvertFromPDFWithHandler: 966565888

            2010.10.13 00:15:49:812 pid: 6352, tid: 6596: Memory after AVConversionConvertFromPDFWithHandler: 964751360

             

            2010.10.13 00:16:48:421 pid: 6352, tid: 6596: Memory before AVConversionConvertFromPDFWithHandler: 941375488

            2010.10.13 00:16:53:062 pid: 6352, tid: 6596: Memory after AVConversionConvertFromPDFWithHandler: 939618304

             

            Well, while it doesn't grow each time by 10 MB as with initial call, it still grows by about 2 MB on each call after that.

             

            So, if called in that way for let say 101 PDFs - then I'll loose about 210 MB of memory and if I want to process even more files without Acrobat restart - probably it will crash at some point.

            • 3. Re: AVConversionConvertFromPDFWithHandler for jpeg memory leak?
              lrosenth Adobe Employee

              Check that you are properly closing & releasing all the objects you are using...

              • 4. Re: AVConversionConvertFromPDFWithHandler for jpeg memory leak?
                andrejusc Community Member

                Yes, I do all those AVCommand/ASCab objects (which are usually involved in such conversion) destroy on each iteration in form like this:

                 

                  ASCabDestroy(settings);
                  ASCabDestroy(config);
                  ASCabDetachPointer(inputs, kAVCommandKeyPDDoc, PDDoc, NULL);
                  ASCabDestroy(inputs);
                  AVCommandDestroy(cmd);
                  if (pdDoc) PDDocClose(pdDoc);
                  if (jpegDstFile) ASFileSysReleasePath(ASGetDefaultFileSys(), jpegDstFile);

                So, I can't think about anything else, which could still consume memory by 2MB chunks on each call