on 04-13-2017 3:18 PM
Problem is that CR leaks memory, especially when using the viewer. I found this posting which describes the proper way to dispose of that memory:
In my code I am using the method described here:
http://www.codeproject.com/Articles/12308/Using-WinForms-controls-in-an-MFC-dialog<br>;
Problem is that in C++, I cannot call ->Dispose(). It tells med to call the destructor ~ReportViewer instead.
Can someone provide an example how to properly end a report on screen so that all memory is released? This is what I have now and it has improved the leaks that used to be 13Mb so that it is now under 1Mb:
void CFloaterDlg::OnClose()
{
CrystalDecisions::CrystalReports::Engine::ReportDocument ^Report;
Report = (CrystalDecisions::CrystalReports::Engine::ReportDocument ^)m_Viewer->ReportSource;
Report->Close();
//
m_Viewer->ReportSource = nullptr;
m_Viewer->~CrystalReportViewer();
//delete m_Viewer;
//
GC::Collect();
GC::WaitForPendingFinalizers();
GC::Collect();
//
//
CDialog::OnClose();
//
m_Viewer.DestroyWindow();
DestroyWindow();
}
Question is how and when to destroy the underlying ReportDocument. Does the viewer hold a copy of the data? Ie can the ReportDocument be destroyed before the viewer is?
Get the lastest update from here:
https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still confused. When I see this in the crystal log file, I would assume that there is no resources in use anymore and that garbage collect would free memory??
Also. I am sort of wondering about the relationship between the ReportDocument and the Viewer as indicated in my original question.
.\..\src\crpe\crpe.cpp:826,Closing engine,After close engine use count,"0"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.