OCR SDK Knowledge Base

Article ID: 1470 | Category: Programming Aspects | Type: Tips & Tricks | Last Modified: 4/16/2015

Not enough storage is available to complete this operation.

Error code is E_OUTOFMEMORY, error description is "Not enough storage is available to complete this operation", "Out of memory", "Not enough memory".


For some documents I have the "not enough memory" exception raised.


Please see below the recommendations that should help you to prevent “not enough memory/storage...” issue:

• Processing multi-page documents

100-page document is considered as a quite large document. 100 ImageDocument and Layout objects may use up to 2 Gb or more in 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 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.

261 people think this is helpful.
Was this information helpful to you?