hi,
i have a big database with customer that we are doing mail merges for thousands of envelopes to be shipped to them.
so i use the document control and the mail merge functions of your library now for years.
but recently our clients grown more and i have notice that when we try to save the doc as PDF export, it crashes with error "out of memory" when the doc has like 1.000pages or 1.500pages or 2.000pages.
with the latest v20.1.7 trial i was testing we noticed a significant improvement now we can save sometimes even 2.000pages but is SOMETIMES! the out of memory error still happens and my application is stuck in 1024,4MB of RAM usage all the time! this looks like a memory leak right?
can you please test exporting again and again 2.000pages in pdf?
regards
John
Hi John,
OutOfMemoryException is thrown when no more memory can be allocated for an application (see the OutOfMemoryException Class Microsoft docs). To investigate why the exception is thrown or why memory leaks occur, use any .NET memory profiler like VS built-in one (suits for simple cases), or dotMemory, or any another one.
To give you more detailed recommendations, we need to research the code where you export documents to PDF. Please encapsulate this code into a smaller project and send it to us.
Also, check if your application is built in x86 mode. If so, change the build mode to x64 to compile your project as a 64 bit process and to overcome the 2 GB RAM limitation for 32-bit processes.
See also: Why do 32-bit processes have a 2 GB RAM limit?
hi Yulia,
my app is not doing enything else that moment to cause a memory leak, just tries to export the doc as pdf in a tmp path and then copy it to the user's choice (thats because the app is been running as RDP application so it needs to save localy in the server the pdf and then copy it to user's remote disk \ path).
here is my super simple code and yes my app is ofcourse compibled as "anyCPU" and not prefer 32bit and in my os is always running as 64bit not 32*. is very weird that when the exception is happening the app is stuck then as i mentioned at exactly 1024MB ram usage! cant go higher doesnt go lower either!
Private Sub btnPdfExport_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnPdfExport.ItemClick If Me.SaveFileDialog1.ShowDialog = DialogResult.OK Then Dim theFile As String = "tempdocfile.pdf" Me.RichEditControl1.ExportToPdf(appDir & theFile) ' OutOfMemory is happening here If IO.File.Exists(appDir & theFile) Then FileCopy(appDir & theFile, Me.SaveFileDialog1.FileName) End If MsgBox("Document Saved.", MsgBoxStyle.Information) End If End Sub
just in case i also turned off the DEP for all apps and left it only for windows services and essentials.
also can this be another reason that i read here? windows server 2016 enterprise:
https://docs.microsoft.com/en-us/troubleshoot/windows-server/performance/desktop-heap-limitation-out-of-memory
will try to reproduce with the changes but is not easy cant make permanent changes to this database, andis 22GB to take backup and play arround.
i made some modifications to allow the app to go crazy and use as much ram as it wants… also disabled DEP…
but what i noticed is that when i load data to populate my girds or to make the mail merge i was referring above… i use EF 6.4.4. and LINQ
load everything to local object class of the dbcontext .
i know is best practice and i do a disposal of the dbContext once i am done and keep making new to load the next batch of records and then binding it to your control with new binding source (local.customer) for example.
BUT even i dispose, even though i do
mydvCon = new dbcontext
then load on local and then bind the data
the memory usage is keep been increased every time i run those linq queries !
is like the old records even though i don't see them are stuck somehow in a RAM cache or objects and new are keep added up.
for example my loading function of customers load the RAM with 500mb… thats ok for 52.000r records and calculations on the fly… but when i run the load again…the app goes to 1gb, then again to 1.5gb and will keep add up ram usage until the O.S tries to clean it.
probably this is also happening with the export to pdf…
it should reset to -500 and then load up again not been increased every time around functions.
have you seen this before. everything I google doesn't seem to solve my issue.
maybe is related to the pdf export.
Private Sub LoadAllContacts() Me.Cursor = Cursors.WaitCursor Call ResetCritiria() myDB.Dispose() GC.Collect() myDB = New dcrmDBEntities() myDB.Configuration.AutoDetectChangesEnabled = True Me.ContactsBindingSource.DataSource = GetType(Contacts) Dim results = (From items In myDB.Contacts Where items.visible = True And items.login_companyID = Common.LoginCompanyID Order By items.id) results.Load Me.ContactsBindingSource.DataSource = New BindingSource() With {.DataSource = myDB.Contacts.Local.ToBindingList()} Me.Cursor = Cursors.Default GC.Collect() End Sub
what am i doing wrong? this is driving me crazy here