Error "Not enough storage is available to complete this operation: E_OUTOFMEMORY" may appear during the processing.
This issue often appears when system's resources are not enough to process the document.
Please see below the recommendations that should help you to prevent “not enough memory/storage...” issue:
• Processing multipage documents
100-page document is considered as a quite large document. 100 ImageDocument and Layout objects may use up to 2 GB or more of virtual memory, not mentioning the memory required for image processing.
We recommend you to use the following settings:
IFRDocument::PageFlushingPolicy = PFP_FlushTo Disk
IPrepareImageMode::ImageCompression = IC_Compress
IPrepareImageMode::KeepOriginalCoordinatesInfo = false (starting from FRE11 R5)
Please read more about these settings in help file.
Please note that temporary objects are stored to %TEMP% folder. It is possible to change folder for temporary files by modifying frDocument.TempDir property (this folder should be created in advance) before calling frDocument.AddImageFile() method. The other side of PageFlushingPolicy = PFP_FlushToDisk is that you should have sufficient free space on the drive where temporary files are stored. For 100-page document, we would recommend you to have at least 5-10 GB free.
• Accessing sub-objects
We do not recommend you to make long chains of sub-objects: object0.subobject1.subobject2. … .subobjectN as it may lead to memory leak.
The better approach is to split such chains:
SubObject1Type object1 = object0.subobject1
SubObject2Type object2 = object1.subobject2 ...
In the end, when you don’t need these objects, they should be set to nil value.
• Deinitializing Engine periodically
Sometimes deinitializing Engine from time to time may help to prevent memory issues. For example, you may call deinitialize Engine and initialize it again every 1000 images.
Our developers recommend to call GC.Collect, GC.WaitForPendingFinalizers before the DeinitializeEngine method and after processing each FRDocument, and Marchal.ReleaseComObject for all objects.