In our software, we using iTextSharp to generate payment checkbooks In some case, we need generate 10 000 file in a time, we run it under Windows Services, and then, we have got problem as folow: After generate completed, the RAM of service very larger, althrough we have call GC.Collect and release all variables.
I take a day to resolve it and finaly I found that: The FontFactoryImp class in iTextSharp has a hashtable name fontFamilies, it holding many memory and never be released. In detail, I see it have many duplicate values !. So, I resolved it by clear that hashtable in finaly by
iTextSharp.text.FontFactory.FontImp = new iTextSharp.text.FontFactoryImp();
GC.Collect(GC.MaxGeneration);
and everything is Ok but it look like cheating.
The question is: Have any wrong or risk in my solution?