The EXE I'm running does not finish (the process is still active) in the Task Manager's list. Even after I unload all the forms and "END".
Is there anyway to detect which object avoids it from unloading??
Printable View
The EXE I'm running does not finish (the process is still active) in the Task Manager's list. Even after I unload all the forms and "END".
Is there anyway to detect which object avoids it from unloading??
Mc Brain,
Detect the objects, no. You will have to go throught your code and make sure that when you load the object that you set it to Nothing when you are done with it.
Use this to exit your application:
VB Code:
For Each Form in Forms unload Form set form = nothing Next Form
Here is my routine that exits a program properly, after closing all forms and releasing all objects.
VB Code:
Private Sub ExitProgram_Click() Dim frm As Form Dim obj As Object If InventoryDeducted = False Then Call CloseInv ' If Necessary ! For Each frm In Forms If frm.Name <> Me.Name Then ' Unload this form LAST For Each obj In frm On Error Resume Next Unload obj Set obj = Nothing Next Unload frm Set frm = Nothing End If Next On Error Resume Next For Each obj In frm Unload obj Set obj = Nothing Next Set frm = Nothing Unload Me End Sub
I'm already using a similar code... but it does not end.
What's more astonish... is that it refuses to END (see the last line of code).VB Code:
Dim frm As Form Set Juego = Nothing Set MessagesToServer = Nothing Set Canto = Nothing Set Dichos = Nothing ' Set Quejas = Nothing Set fTablero = Nothing Set StBy = Nothing Set ImgLst = Nothing Set tFallo = Nothing Set OtroJuego = Nothing For Each frm In Forms If frm.Name <> Me.Name Then Unload frm Set frm = Nothing End If Next If udpPeer.State Then udpPeer.Close End 'Just In Case
I encountered this problem a week ago.... the problem was my Unload event code... it was accessing a form's property which resulted in the loading of that form again... I also tried using End but that didn't work as eventually the conditions which lead to End statement were becoming false in Load Event of form...Quote:
Originally Posted by Mc Brain
You don't unload Me. Try using my code to see if it makes any difference.
Are you stepping thru the code to make sure that it runs?
I cannot step through the code... on the IDE it ends smoothly.Quote:
Originally Posted by dglienna
Mc Brain,
Search your code for any clauses like:
Set <object> = <object>
and make sure that these object are set to Nothing.
After the Finalizar subroutine (which code is the one I posted before)... it executes nothing!! Here's the mkcDebugger's log.Quote:
Originally Posted by moinkhan
Quote:
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: Globals GetSetting
*Tute v1.0.0*: Registry GetSettingString
*Tute v1.0.0*: frmTablero Form_Resize
*Tute v1.0.0*: frmTablero Form_Activate
*Tute v1.0.0*: Globals GetSetting
*Tute v1.0.0*: Registry GetSettingString
*Tute v1.0.0*: frmTablero TB_ButtonClick
*Tute v1.0.0*: frmTablero submnu_Salir_Click
*Tute v1.0.0*: frmTablero EnRed
*Tute v1.0.0*: frmTablero Form_QueryUnload
*Tute v1.0.0*: frmTablero Form_Unload
*Tute v1.0.0*: frmTablero Finalizar
I don't know what happened... but it's working now. :confused:
No, it doesn't!
I don't understand what's going on. If I run this exe in my computer (W2K), it ends correctly. If I run this exe at work's computer (XP), the process does not end. What's even worse the CPU goes to 99% (for this process).
Does anybody know what my be going on? :confused:
Is your exe listed on the Applications or in the Processes? Sometimes I also encounter the same problem with VB6, its not listed in the applications but is listed in the processes and CPU usage really rises.....
it sounds as if you maybe calling the unload from a loop, which continues after unloading all. immediately after calling unload me, try exit sub
pete
What does this line do?
VB Code:
If udpPeer.State Then udpPeer.Close
Is it a winsock? Maybe that line is the beast?
It's on both lists.Quote:
Originally Posted by dee-u
Why would it work at my home's computer?Quote:
Originally Posted by westconn1
It's a winsock. If it has an open port (UDP) it closes it. It's not connected with any machine, it's not TCP it is just listening to a port... just in case any other instance of the game "talks" to it.Quote:
Originally Posted by dee-u
The Finalizer event? That event is only fired when there is no references left to your class or form. Try moving it to the Unload event instead.Quote:
Originally Posted by Mc Brain
On a side note... I see this code all the time (several time in this thread):Now what does the line that sets frm to Nothing do? It destroys the frm reference which will be destroyed anyway when the Next statement runs since it then references another form. Let's say I have a Form called Form2 and I use this code:VB Code:
Dim frm As Form For Each frm In Forms Unload frm Set frm = Nothing NextIn the above code I have two references to the same object. Setting frm to Nothing will destroy one of them not the origional one.VB Code:
Dim frm As Form Form2.Load '<-- creates the Form and uses the Form2 reference Set frm = Form2 '<--- Let frm reference Form2
Ok, my mistake. I should not have called it "event". It's not actually an event but a subroutine. The Finalizar subroutine gets called whenever I say so (which is in the Form_Unload).Quote:
Originally Posted by Joacim Andersson
I knew this... but I added that line (just in case). You never know what else to try.Quote:
Originally Posted by Joacim Andersson
Actually, I think you have a loaded form and a reference (pointer) to it. This code:Quote:
Originally Posted by Joacim Andersson
VB Code:
Option Explicit Private frm As Form Private Sub Command1_Click() Unload frm Set frm = Nothing End Sub Private Sub Form_Load() Load Form2 '<-- creates the Form and uses the Form2 reference Form2.Show Set frm = Form2 '<--- Let frm reference Form2 End Sub
would close the only Form2 loaded and then point to nothing. Anyway, I still don't understand where you're trying to get.
In your example you set frm to nothing but you don't set Form2 to nothing. Both of those object pointers or references exist, setting one to nothing but not the other is about the same thing as you don't put any to nothing.
Anyhow... Try moving the line that closes the winsock to before you start unloading each form.
Isn't that what Unload Form2 is for?Quote:
Originally Posted by Joacim Andersson
Wow!! How didn't I realize of that before. Anyway, I did move the line (which is safer), but still not closing.Quote:
Originally Posted by Joacim Andersson
Unload Form2 will unload the visual parts of the form. It will not unload the code itself. Why would you set the reference to Nothing if it was OK to just unload it (which it is in most cases).Quote:
Originally Posted by Mc Brain
I don't know. I also don't know why we're discussing about an example or about something that is not needed instead of what should be changed or added in the real code. ;)Quote:
Originally Posted by Joacim Andersson
Well, as I mentioned in my origional apply:Quote:
Originally Posted by Mc Brain
The key word here is On a side note.... Nothing to do with your question at all :) so let's not get ourself stuck on that issue.Quote:
Originally Posted by Joacim Andersson
I do understand that posting your project would be a lot to ask for but I it would be very helpful to be able to see this behaviour with my own (bug seeking :)) eyes.
Yes, it does. It's a 90% working net-game... and would not like anyone on this planet be able to download the whole code.Quote:
Originally Posted by Joacim Andersson
Whenever I finishs it, I will consider releasing its code... but it does not outlook so good right now. ;)
Edit: What the h... was "net-working game"? Were you high??? ;) I'm not fan with "working net-game" either, but I guess it explains better
I think "End" was the problem. I remove the "just in case" End... and the process removed itself from memory as if everything was correctly deleted. :confused:
VB Code:
Private Sub Finalizar() If mkcDebug Then DebugPrint "frmTablero Finalizar" Dim frm As Form Set Juego = Nothing Set MessagesToServer = Nothing Set Canto = Nothing Set Dichos = Nothing ' Set Quejas = Nothing Set fTablero = Nothing Set StBy = Nothing Set MessageIDHistory = Nothing Set ImgLst = Nothing Set tFallo = Nothing Set OtroJuego = Nothing If udpPeer.State Then udpPeer.Close For Each frm In Forms Unload frm Set frm = Nothing Next 'End 'Just In Case If mkcDebug Then DebugPrint "frmTablero Finalizar - Out" End Sub
Are you using multithread? I guess sme threads are not quiting.
It's finishing correctly now.Quote:
Originally Posted by temp_12000