Hi,

It'll not work because this is unmanaged memory leak. Unmanaged memory
is clean up when process finish.
The only solution is to start a new process for OCR.
http://social.msdn.microsoft.com/Forums/en-US/clr/thread/20de15d6-3111-4c2e-a04b-feb341a67ebc

Remi

On Sep 20, 6:29 am, nicdnepr <[email protected]> wrote:
> i tried msdn method with dynamically load\unload assembly to domain, but it
> still eat much memory
>
> my code is
>
> Bitmap b = new Bitmap(@"d:\0.bmp");
>                 AppDomainSetup setup = new AppDomainSetup();
>                 // setup.ApplicationBase = @"c:\temp\";
>                 AssemblyName assName = AssemblyName.GetAssemblyName(ass);
>                 Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
>                 Evidence evidence = new Evidence(baseEvidence);
>                 AppDomain newDomain = AppDomain.CreateDomain("newDomain",
> evidence, setup);
>                 Assembly a = newDomain.Load(assName);
>
>                 Type myType = a.GetType("tessnet2.Tesseract");
>                 MethodInfo mymethod = myType.GetMethod("Init");
>                 Object obj = Activator.CreateInstance(myType);
>                 mymethod.Invoke(obj, new object[] { null, "eng", false });
>                 mymethod = myType.GetMethod("DoOCR");
>                 obj = Activator.CreateInstance(myType);
>
>                 object o = mymethod.Invoke(obj, new object[] { b,
> Rectangle.Empty });
>
>                 label1.Text = ((List<tessnet2.Word>)o)[0].Text;
>
>                 AppDomain.Unload(newDomain);
>
> 2009/9/18 Svetlin Nakov <[email protected]>
>
>
>
> > It is well known that Tesseract has multiple memory leaks so I think you
> > can
> > periodically unload the managed wrapper .NET assembly and load again. To do
> > so you could load it in a separate application domain and unload the entire
> > domain and re-create it periodically (e.g. when the memory consumption
> > reaches some threshold).
>
> > See more about application domains, loading and unloading assemblies at
> > runtuime here:http://msdn.microsoft.com/en-us/library/ms173101.aspx
>
> > Regards,
>
> > Svetlin Nakov
> > Managing Partner
> > Consulting and Information Technology Agency
> >http://www.citagency.eu
>
> > -----Original Message-----
> > From: [email protected] [mailto:
> > [email protected]]
> > On Behalf Of nicdnepr
> > Sent: Friday, September 18, 2009 3:06 PM
> > To: tesseract-ocr
> > Subject: memory problem
>
> > hi
> > i use Tessnet2 a .NET 2.0 Open Source OCR assembly using Tesseract
> > engine
> > from articlehttp://www.pixel-technology.com/freeware/tessnet2/
> > after 1000 persed images i have 500 MB memory used in program. how can
> > i resolve this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tesseract-ocr?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to