pdf - Releasing memory held in objects in VB.NET -
i using 3rd party dll pdf-tools parse pdf files inside vb.net application , write extracted data sql localdb database. i'm giving user 2 options: select pdf file parsing or point folder , application loop through pdf files inside it. both options call same procedure dopdffile() below.
the problem is: if import number of files individually selecting file every time, program runs fine. however, if select folder contains same files, memory used program keep growing further , further. in windows task manager, can reach 1 gb after importing around 30 files.
i used ants memory profiler redgate, , showed 1 object called "graphicsstate" part of pdf-tools object growing big when looping inside folder. not happen if select same files 1 one. besides memory problem, application becomes slow after parsing files. questions is: why happening? , how prevent it? user should able point program folder hundreds of pdf files, how can achieve this?
below snapshot of code:
'when user selects 1 file private sub opentoolstripmenuitem_click(...) openfiledialog1.filename.tostring dopdffile() end sub 'when user selects folder private sub looptoolstripmenuitem_click() handles looptoolstripmenuitem.click folderbrowserdialog1.showdialog() spath = folderbrowserdialog1.selectedpath each filename string in io.directory.getfiles(...) spath = filename dopdffile() next end sub inside dopdffile() procedure, i'm doing following, i'm using document object pdf-tools , i'm passing byref procedure:
public sub dopdffile() using document new pdftools.pdfextract.document document.open(spath) findfirstpage(document) 'passing reference parsefirstpage(document) 'passing reference 'storing parsed text in array '....... 'extracting colors graphicsstateobject inside document object: using objgraphicsstate pdftools.pdfextract.graphicsstate = content.graphicsstate scolor = objgraphicsstate.fillcolorrgb end using 'save text , color in array of objects until endoftext end using end sub
Comments
Post a Comment