How to make MODI.Document not leak memory? I have millions of images to OCR but each time i OCR one

Discussion in 'Microsoft Dot NET Framework' started by DR, Feb 4, 2008.

  1. DR

    DR Guest

    How to make MODI.Document not leak memory? I have millions of images to OCR
    but each time i OCR one it leaks memory. How to do the OCR and then clean up
    so that my app doesnt leak memory?

    MODI.Document miDoc = new MODI.Document();
    for (int i = 0; i < 1000; i++)
    {
    miDoc.Create("a.gif");
    miDoc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
    MODI.Image tifImg = (MODI.Image)miDoc.Images[0];
    string recSTring = tifImg.Layout.Text;
    miDoc.Images.Remove(tifImg);
    miDoc.Close(false);
    }
    int i23z = 23 + 23;
    miDoc.Close(false);
     
    DR, Feb 4, 2008
    #1
    1. Advertisements

  2. DR

    Scott M. Guest

    I'm assuming that MODI.Document() is a COM object?

    If so, you need to call Marshal.ReleaseComObject Method to tell the CLR that
    it should release its hold on the underlying COM object.

    http://msdn2.microsoft.com/en-us/li...interopservices.marshal.releasecomobject.aspx



    "DR" <> wrote in message
    news:...
    > How to make MODI.Document not leak memory? I have millions of images to
    > OCR but each time i OCR one it leaks memory. How to do the OCR and then
    > clean up so that my app doesnt leak memory?
    >
    > MODI.Document miDoc = new MODI.Document();
    > for (int i = 0; i < 1000; i++)
    > {
    > miDoc.Create("a.gif");
    > miDoc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
    > MODI.Image tifImg = (MODI.Image)miDoc.Images[0];
    > string recSTring = tifImg.Layout.Text;
    > miDoc.Images.Remove(tifImg);
    > miDoc.Close(false);
    > }
    > int i23z = 23 + 23;
    > miDoc.Close(false);
    >
     
    Scott M., Feb 4, 2008
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sijin Joseph

    Re: MODI Management

    Sijin Joseph, Aug 27, 2004, in forum: Microsoft Dot NET Framework
    Replies:
    0
    Views:
    223
    Sijin Joseph
    Aug 27, 2004
  2. David de Passos

    OCR with MODI

    David de Passos, Sep 1, 2004, in forum: Microsoft Dot NET Framework
    Replies:
    0
    Views:
    524
    David de Passos
    Sep 1, 2004
  3. Klaus Jensen

    OCR scanning images from code

    Klaus Jensen, Dec 1, 2005, in forum: Microsoft Dot NET Framework
    Replies:
    10
    Views:
    512
    Dick Grier
    Dec 12, 2005
  4. DR
    Replies:
    3
    Views:
    1,401
    Alvin Bruney [ASP.NET MVP]
    Feb 8, 2008
  5. cdev1

    MODI drag drop - Microsoft office document imaging

    cdev1, Apr 24, 2008, in forum: Microsoft Dot NET Framework
    Replies:
    0
    Views:
    382
    cdev1
    Apr 24, 2008
Loading...

Share This Page