You are viewing limited content. For full access, please sign in.

Question

Question

Not enough storage is available to process this command

asked on June 17, 2015

While exporting about 1000 documents from a particular folder, at a random stage of the process the remaining files are exported as empty, with the following log entry

System.ComponentModel.Win32Exception (0x80004005): Not enough storage is available to process this command
   at MS.Win32.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
   at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
   at System.Windows.Threading.Dispatcher..ctor()
   at System.Windows.DependencyObject..ctor()
   at System.Windows.Media.Imaging.BitmapSource..ctor()
   at Laserfiche.Imaging.LfiWriteableBitmap..ctor(Stream streamSource, Int32 frameIndex)
   at Laserfiche.Imaging.LfiBitmapDecoder.GetBitmap(Int32 frameIndex)
   at Laserfiche.DocumentServices.ImageExporter.DecodeBitmap(LfiBitmapFrame frame)
   at Laserfiche.DocumentServices.ImageExporter.ExportImages(Stream outputStream)
   at Laserfiche.DocumentServices.DocumentExporter.ExportPages(IDocumentContents document, PageSet pages, Stream outputStream)
   at Laserfiche.DocumentServices.DocumentExporter.ExportPages(IDocumentContents document, PageSet pages, String outputPath)
   at WorkflowActivity.Scripting.ExporttoServerFolder.Script1.Execute()

Once the entry in question hits this point, the following documents (exported empty) continue the log this message, except the "error" reads "The operation completed successfully".

 

Also, for all documents exported as empty, the Event Logs report this error

Faulting application name: Laserfiche.Workflow.Activities.83.Processor.exe, version: 9.1.1.395, time stamp: 0x53d928d9
Faulting module name: KERNELBASE.dll, version: 6.3.9600.17278, time stamp: 0x53eebd22
Exception code: 0xc0000142
Fault offset: 0x00000000000ec0b4
Faulting process id: 0x520
Faulting application start time: 0x01d0a889a3a98530
Faulting application path: C:\Program Files\Laserfiche\Laserfiche Workflow 9\Laserfiche.Workflow.Activities.83.Processor.exe
Faulting module path: KERNELBASE.dll
Report Id: e1561158-147c-11e5-80e4-06eb6ca5bd72
Faulting package full name: 
Faulting package-relative application ID: 

I wonder if this kind of error is related to a similar problem I have with an ongoing Email workflow. What can happen is that Emails with attachments outbound of this workflow (triggered by an event) can end up being sent without any attachment. A restart of the Laserfiche Workflow Service & Subscribe resolves the issue, but the symptoms are very similar to that described above.

 

For the file export, I'm using a Workflow SDK Activity via the DocExporter (nothing fancy)

For the email export, I'm using a Workflow Email Activity.

 

Any suggestions?

1 0

Answer

SELECTED ANSWER
replied on June 19, 2015

This is a bug in how DocumentServices uses Laserfiche.Imaging. Laserfiche.Imaging calls into Windows Presentation Foundation (WPF) when annotations are requested. WPF has a window handle leak under certain conditions, which causes it to error out when the maximum number of windows are created. I wasn't able to reproduce the issue exporting just 1000 documents, but it does manifest itself if i run this workflow a few times.

We are looking into fixing it, but the fix is non-trivial and a hotfix is not possible at this time.

As a workaround, you can switch to using LFSO90 and DocumentProcessor90 to export documents. These libraries do not call into WPF, so the issue will not occur. Both files are installed with Workflow, and they'll continue to be installed in newer versions, so you won't have to worry about these scripts during upgrades. One thing to note is that they are COM libraries rather than .Net assemblies, so the export will be slightly slower due to the added .Net/COM communication.

I'm attaching the modified script. You will need to:

  • Add references to Interop.LFSO90Lib.dll, Interop.DocumentProcessor90.dll
  • Change "public class Script1 : RAScriptClass92" to "public class Script1 : SDKScriptClass90"

 

namespace WorkflowActivity.Scripting.SDKScript
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using LFSO90Lib;
    using DocumentProcessor90;
    using System.IO;
    using System.Drawing;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : SDKScriptClass90
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            String sMasterLogLocation = "C:\\EXPORT_LFSO\\LOG_"+DateTime.Now.ToString("yyyyMMdd") + ".txt";
            try
            {

            LFDocument doc = (LFDocument)this.Entry;

            string sChannel = "VAL";
            string sAppNumber = TokenReplace("RetrieveFieldValues_Document");
            string sDocCreationTime = doc.CreateDate.ToString("yyyyMMddHHmmss");
            string sDocCreationDate = doc.CreateDate.ToString("yyyyMMddHH");
            int nEntryID = doc.ID;
            string sFileName = sChannel + "_" + sAppNumber + "_" + nEntryID + "_" + sDocCreationTime;
            DocumentExporter docExporter = new DocumentProcessor90.DocumentExporterClass();
            string sFilePath = "C:\\EXPORT_LFSO\\" + doc.CreateDate.ToString("yyyy") + "\\"+ doc.CreateDate.ToString("MM") + "\\" +
            doc.CreateDate.ToString("dd") + "\\" + doc.CreateDate.ToString("HH");
            if (!System.IO.Directory.Exists(sFilePath))
            {
            System.IO.Directory.CreateDirectory(sFilePath);
            }
            string sTempFileName = sFilePath+"\\"+sFileName + ".tif";
            string sFolderLogLocation = sFilePath + "\\LOG_" + sDocCreationDate + ".txt";
            //Export
            //IDocumentContents doc2 = doc.GetLatestVersion();


            LFDocumentPages dpages = (LFDocumentPages)doc.Pages;
            // Marks page to be exported.
            dpages.MarkAllPages();
            // Instantiates a new document exporter.
            DocumentExporter DocE = new DocumentExporter();
            // Adds the marked pages to the document exporter.
            DocE.AddSourcePages(dpages);
            // Specifies the format for the exported document.
            DocE.Format = Document_Format.DOCUMENT_FORMAT_TIFF;
            DocE.BlackoutRedactions = true;
            // Exports the document.
            DocE.ExportToFile(sTempFileName);
            // Clears unused handles.
            doc.Dispose();

            }
            catch (Exception ex)
            {
            WriteLogs(ex.ToString(),sMasterLogLocation);
                WorkflowApi.TrackError(ex);
            }
            }
            public void WriteLogs(string sLog, string sLogLocation)
            {
            StreamWriter sw = new StreamWriter(sLogLocation, true);
            sw.WriteLine(DateTime.Now.ToString("yyyyMMddHHmmss") + "||" + sLog);
            sw.Close();
            }
            }


}

 

1 0

Replies

replied on June 17, 2015

Workflow Image and SDK attached.

 

Thanks

TEST_Export.png
TEST_Export.png (15.05 KB)
SDK_Export.txt (2.92 KB)
1 0
replied on June 18, 2015

Thanks for your information. We are investigating this issue and will post an update here when we have more information for sharing.

0 0
replied on June 19, 2015

Thanks Ryan. Our current VAR is not engaging with us on this so appreciate the direct Laserfiche support.

0 0
replied on June 19, 2015

Hi Michael.

 

We are currently looking into the issue and have created a support ticket with Laserfiche which has the id 167786. We are also looking into the script.

 

Thanks,

Brian

1 0
replied on November 24, 2015

This is a status update on this issue.

The upcoming SDK Version 10 will contain a fix for this issue.

1 0
replied on June 17, 2015

This looks like a problem. Please have your VAR open a case with Support.

0 0
replied on June 17, 2015

Can you post the export code? It looks like it's initializing some UI threads and not disposing correctly of its resources causing the memory leak that results in "not enough storage available".

0 0
replied on June 19, 2015

Worked a charm. Thanks very much Miruna!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.