|
Hi,
I have "inherited" a VB.NET application with many child windows that each take care of different tasks. The parent application (window) gets started in the morning and gets closed in the evening, and all during the day child windows will be opened and closed. My predecessor did not always follow best practices in his coding. As a result the application does not always free up the memory it used after a certain child window gets closed. I.e. the task manager shows an ever increasing amount of memory usage for the application as the day progresses.
The question is, will adding Me.Dispose() to the closing event of each child form do the trick, or is there some other simple way to free up memory when closing a (child) window, without closing the entire application?
All (friendly) suggestions appreciated,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Dispose will do the trick. If you're reusing the same forms, the other thing is to make it a member and only ever create one.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi frnd,
did you try
gc.waitforpendingfinalzer()
use gc object(garbage collect)
hope it helps,
-koolprasad2003
Be A Good S/W Eng... Life is swing with you..Enjoy..
|
|
|
|
|
You don't normally put Me.Dispose in the forms Closing event.
Depending on how a form is shown and what the form is doing will dictate when you call Dispose. For instance, every form shown with .ShowDialog() MUST be Disposed when you're done with it. Since a ShowDialog call returns a DialogResult from the form, calling Me.Dispose in the dialog form's Closing event would be very premature.
After you get the DialogResult from the ShowDialog method, you should get the data and information you need from that form, THEN call Dispose on the form object:
Dim myDialog As New MySettingsDialog
If myDialog.ShowDialog(Me) = DialogResult.Ok Then
' Get any needed data from the Settings Dialog
End If
myDialog.Dispose()
|
|
|
|
|
You should pretty close to never call the garbage collector.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Dave,
Talking about good practices. Thanks, that finally also clears up the difference between myForm.Show() and myForm.ShowDialog(). Shame on me, but I didn't know, and never bothered to find out.
In this case I found that the parent form of the application does initiate all child forms with .ShowDialog(), although no data seems to get returned. Just to stay on the safe side though, I followed your advice and used myForm.Dispose() everywhere in the parent form, instead of in the child forms.
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,
My experience with the garbage collector is limited to seeing the guy empty the trash can outside my house.
What does the garbage collector do other/more/less than the dispose method?
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
.ShowDialog() returns a DialogResult that the form sets before it closes. Look up the docs on .ShowDialog() and it'll show you an example.
|
|
|
|
|
Dispose cleans up resources. The GC clears the memory. But, it does this in a highly optimised way, automatically. Callnig it yourself is pretty close to always just going to slow things down
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Okay thanks, that is really good to know. And thanks for the help.
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hey Guys
I have problem inserting single and double quotes in DB
How can i insert single Quote and Double Quotes in DB
Can You provide me a simple code for that
Regards
Ramy
|
|
|
|
|
hi, use this one
q = "select * from main where lotnumber like " & """" & ComboBoxlotnumber.Text.Trim & "%" & """"
here ComboBoxlotnumber.Text.Trim may contain single & double quotes
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Apostrophes inside a string in SQL has to be encoded, and depending on what database you are using, backslashes also. There is nothing special about quotes in a string, so if you have problem with them, there is something else that you are doing wrong.
For MySQL: Replace "\" with "\\" and replace "'" with "\'" (in that order).
For MSSQL, Access: Replace "'" with "''".
---
single minded; short sighted; long gone;
|
|
|
|
|
|
Hi!
Please help me how to disable and enable Task Manager in vb.net.
Best Regard
Jayson
More problems
More Knowledge to gain
Just keep on going
|
|
|
|
|
You really can't, and I can't imagine a non hostile reason for wanting to.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi
It is not possible ... but command for running it is taskmgr.exe.. Just try out to stop this process using this command
Harini
|
|
|
|
|
It can be done through Group Policy, not through your code. Unless you're building a kiosk machine, there's really no reason to do this.
Get your hands on the Windows XP or Windows Server 2003 Resource Kit (from Amazon) and either of those nice thick books will explain what Group Policies are and how they work in different networking or non-networked environments.
|
|
|
|
|
hi,
I want to know the Path of the Parent folder of Particular File/Folder. How can i achieve this thing in VB.net.
Thanks in Advance
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
|
How do i convert Excel database file to Sql server database file dynamically?
Cynara
|
|
|
|
|
If you mean getting the data from an Excel spreadsheet into SQL Server, where the spreadsheet is in a known format, I would read the data from your spreadsheet a line at a time and check for errors, then insert using an SQL Statement.
If this isn't what you were getting at, feel free to provide more information.
-------------------------------------------------
Damian - <insert something="" useful="" here="">
|
|
|
|
|
Excel is not a database, not even remotely.
You can control Excel using C# code, if you get the Microsoft libraries to do this, and you have Excel installed. Then you can read spreadsheet values and write SQL to put them into any database or other format you like.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How do i convert Excel database file to Sql server database file dynamically?
|
|
|
|
|
hello frnds,
i want to convert RTF document to HTML document in vb.net 2.0
if any one have code, then plzzzz give me
thankx in advance/Best Regards
-koolprasad2003
Be A Good S/W Eng... Life is swing with you..Enjoy..
|
|
|
|