I have a VB NET application.
In a form I am building some charts, using XTRACHARTS library.
All objects inside of that form, was declared PRIVATE.
When I close the form, I need to guarantee that the form IS DISPOSED, in order to release all memory used by it.
Please see the following:
XtraCharts.ShowDialog()
XtraCharts.Dispose()
GC.Collect()
Dim Mem As Process
Mem = Process.GetCurrentProcess(
)
SetProcessWorkingSetSize(M
em.Handle,
-1, -1)
If XtraCharts.IsDisposed Then
msgbox("The form is not disposed")
End If
XtraCharts.IsDisposed ALLWAYS RETURN FALSE, and memory (a lot memory) used by the charts objects was not released..!!
When I execute:
Dim Mem As Process
Mem = Process.GetCurrentProcess(
)
SetProcessWorkingSetSize(M
em.Handle,
-1, -1)
Ok, the amount of free RAM is increased, because all possible pages in RAM was moved to the page file on the hard disk.
But, when I return to the XtraCharts.ShowDialog(), the performance is very slow, because all pages needed by the XtraCharts objects are moved back from the page file on hard disk to the RAM.
These I/O operations "FREEZE" the application for a long time...!!!.
I made another test:
TestFormWithoutCode.ShowDi
alog() '----- this form have not any code
TestFormWithoutCode.dispos
e()
GC.Collect()
If TestFormWithoutCode.IsDisp
osed Then
msgbox("The form is not disposed")
End If
TestFormWithoutCode.IsDisp
osed ALLWAYS RETURN FALSE TOO..!!
What are happening?
How I can do to REALLY DISPOSE a form?
In my case, I believe that the SetProcessWorkingSetSize(M
em.Handle,
-1, -1), is not a good solution (I was found a lot information about it).
I need to find a way to REALLY RELEASE that objects ..!!!!, and the next time I need it, simply create it again, all in memory, of course. I dont want swap to the hard disk that objects...!!!
In my case, I believe that I have 2 options:
1) Found a way to REALLY CLOSE, DISPOSE, AND REALEASE all objects and resources included inside of XtraCharts form.
2) Create another VB project XtraCharts, and execute it using Process.Start("XtraCharts.
exe")
(Obviously, I will need to pass the source data to build the charts..!! using some xml file, because I have the source data stored in a grid in the main application).
3) There is a way to RUN the XtraCharts.form in a separate process from the main application and ensure that when it exits, all resources will be released?
I will appreciate any USEFULL COMENTS.
Start Free Trial