Symptoms
The following error may appear during the processing in FineReader Engine 12:
Not enough storage is available to complete this operation: E_OUTOFMEMORY
Cause
This issue often appears when system resources are not enough to process the document.
Resolution
-
When 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.
It is recommended to use the following setting for decreasing memory consumption:IFRDocument::PageFlushingPolicy = PFP_FlushTo Disk
More information about it can be found in the help file.
Please note that temporary objects are stored to %TEMP% folder. It is possible to change the folder for temporary files by modifying IFRDocument::TempDir property (this folder should be created in advance) before calling IFRDocument::AddImageFile() method. The other side of PageFlushingPolicy = PFP_FlushToDisk is that there should be sufficient free space on the drive, where temporary files are stored. For a 100-page document, it is recommended to have at least 5-10 GB of free space.
-
Accessing sub-objects:
It is not recommended to make long chains of sub-objects:object0.subobject1.subobject2. … .subobjectNas it may lead to memory leak.
The better approach is to split such chains:
SubObject1Type object1 = object0.subobject1
In the end, when these objects are not needed, they should be set to null value.
SubObject2Type object2 = object1.subobject2...
-
Deinitializing Engine periodically
Sometimes, deinitializing Engine from time to time may help to prevent memory issues. For example, it is possible to call deinitialize Engine and initialize it again every 1000 images.
It is recommended to call GC.Collect, GC.WaitForPendingFinalizers before the DeinitializeEngine method and after processing each FRDocument, and Marshal.ReleaseComObject for all objects.