473,324 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

App don't stop when closing the form

Hi,
My app does not stop whan I click on the form. I mean, the form is
closing, but the process keeps running in the task manager. So I figured
there are memory leaks or some object's process stuck at some point. Is
there an easy way to know where it comes from other than putting breakpoints
all over the code? 'cause it's huge and I would have to set breakpoints for
at least a day or two

thanks
Jul 21 '05 #1
16 1896
Obviously you have wrong approach on creating and destroying objects
instances.
For all objects that have implemented IDisposable, i suggest you to call
obj.Dispose and set it to obj = Nothing (or null) when you dont need him any
more.

.... it is also possible that you did not exit some loop !?

Regards,
Josip Habjan
URL: http://www.habjansoftware.com


"ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message
news:OS*************@TK2MSFTNGP12.phx.gbl...
Hi,
My app does not stop whan I click on the form. I mean, the form is
closing, but the process keeps running in the task manager. So I figured
there are memory leaks or some object's process stuck at some point. Is
there an easy way to know where it comes from other than putting
breakpoints
all over the code? 'cause it's huge and I would have to set breakpoints
for
at least a day or two

thanks

Jul 21 '05 #2
ThunderMusic,

What do you mean with keeps running, all day long or a short time?

Cor
Jul 21 '05 #3
Josip,
For all objects that have implemented IDisposable, i suggest you to call
obj.Dispose and set it to obj = Nothing (or null) when you dont need him
any more.


All textboxes, panels, forms, comboboxes and other controls and datasets
etc, which are on the forms, which have IDisposable implemented?

Cor
Jul 21 '05 #4
no .. you misunderstand me.. or i explaned wrong....

see:
http://gotdotnet.com/team/libraries/...anagement.aspx

Regards,
Josip Habjan
URL: http://www.habjansoftware.com


"Cor Ligthert" <no************@planet.nl> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
Josip,
For all objects that have implemented IDisposable, i suggest you to call
obj.Dispose and set it to obj = Nothing (or null) when you dont need him
any more.


All textboxes, panels, forms, comboboxes and other controls and datasets
etc, which are on the forms, which have IDisposable implemented?

Cor

Jul 21 '05 #5
And also:
#1: http://weblogs.asp.net/pwilson/archi.../20/77435.aspx
#2:
http://msdn.microsoft.com/library/de...sposeTopic.asp
#3: http://www.codeproject.com/dotnet/GC_101.asp
.... etc...

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
Josip,
For all objects that have implemented IDisposable, i suggest you to call
obj.Dispose and set it to obj = Nothing (or null) when you dont need him
any more.


All textboxes, panels, forms, comboboxes and other controls and datasets
etc, which are on the forms, which have IDisposable implemented?

Cor

Jul 21 '05 #6
Josip,

In your first by you supported link I did not see what you wrote, as well
not on the other from Microsoft. Adviced is that when you use unmanaged
resources to implement Idisposable.

This is already implemented in any class that inherits from component. Which
is 80% of the in my opinion in general most used. And as Jon Skeet ones has
checked 20 % of the actual ones. Disposing is mostly done in the higher
class itself. See for that the part in the hidden part of a form or a
component. This you find back in almost all samples from Microsoft about
dispose.

On the blog page there is an explanation that is for me the same as: "What
does it harm to set all integers that you have created in your procedure to
zero". If you don't understand what I want to say with that. Just leave it,
however this tells for me only something about the knowledge from the
writers of this kind of sentences.

I hope this helps,

Cor
Jul 21 '05 #7
Cor,

From my point of view, MS should keep C++ concept on creating and destroying
objects. If you create new object instance, then you are responsible to
destroy it. In framework, GC may implicate on preformances since he decides
when he will call suppressfinalize. ( I know that he is waiting for best
time, but anyway )....

I have habit to call object.dispose (and =nothing) for every object instance
that i create (except: Usercontrols, string, integer and related types).
This way, i'm shure that my application will close immediate when i close
it, and will not stay in memory for next 5 minutes (waiting for GC to do his
work) ...

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Oh**************@TK2MSFTNGP14.phx.gbl...
Josip,

In your first by you supported link I did not see what you wrote, as well
not on the other from Microsoft. Adviced is that when you use unmanaged
resources to implement Idisposable.

This is already implemented in any class that inherits from component.
Which is 80% of the in my opinion in general most used. And as Jon Skeet
ones has checked 20 % of the actual ones. Disposing is mostly done in the
higher class itself. See for that the part in the hidden part of a form or
a component. This you find back in almost all samples from Microsoft about
dispose.

On the blog page there is an explanation that is for me the same as: "What
does it harm to set all integers that you have created in your procedure
to zero". If you don't understand what I want to say with that. Just leave
it, however this tells for me only something about the knowledge from the
writers of this kind of sentences.

I hope this helps,

Cor

Jul 21 '05 #8
Josip,

I think that we both have a different idea. I keep it by managed code.

However, that from the GC in your application is strange. My experience is
that the GC starts direct as soon as there is a kind of idle time in the
application. Even when the Graphical processor takes over the painting on
screen.

Cor
Jul 21 '05 #9
Josip Habjan <jh*****@SPAM-OFF.net.hr> wrote:
I have habit to call object.dispose (and =nothing) for every object instance
that i create (except: Usercontrols, string, integer and related types).
You can't call Dispose on most types though - there are plenty of types
which don't implement IDisposable.

Also note that setting a variable to nothing is rarely useful, IME.
This way, i'm shure that my application will close immediate when i close
it, and will not stay in memory for next 5 minutes (waiting for GC to do his
work) ...


Disposing of an object doesn't garbage collect it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #10
I mean forever... I must end the task using the task manager...

Someone told something about being stuck un a loop, I'll look into this and
look in all my always running loops.... maybe one does not stop...

thanks

"Cor Ligthert" <no************@planet.nl> a écrit dans le message de
news:%2***************@TK2MSFTNGP12.phx.gbl...
ThunderMusic,

What do you mean with keeps running, all day long or a short time?

Cor

Jul 21 '05 #11
Thundermusic,

Are you using Visual Studio Net. Than just try with setting some breakpoints
if the program is still running. It should not stop in the way you describe
it in my opinion in your debugger too.

I hope this helps,

Cor
Jul 21 '05 #12
excellent idea... thanks

"Cor Ligthert" <no************@planet.nl> a écrit dans le message de
news:u3*************@TK2MSFTNGP10.phx.gbl...
Thundermusic,

Are you using Visual Studio Net. Than just try with setting some breakpoints if the program is still running. It should not stop in the way you describe it in my opinion in your debugger too.

I hope this helps,

Cor

Jul 21 '05 #13
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Josip Habjan <jh*****@SPAM-OFF.net.hr> wrote:
I have habit to call object.dispose (and =nothing) for every object
instance
that i create (except: Usercontrols, string, integer and related types).
You can't call Dispose on most types though - there are plenty of types
which don't implement IDisposable.


I agree, but aso there are planty of types that does implements IDisposable.

Also note that setting a variable to nothing is rarely useful, IME.
May be, and may be not. Why?
Uisng FileStream .. i created new file, write something to it and then i
close it. I next step i tryed to open this same file to append something to
it, but this file was 'locked' from first step where i created it... Why?
Obviously some reference to this file is still hanginge somewhere in the
air!? I can only tell you that i tryed this fiew times and only thing that
helped is setting 'FileStream = Nothing' after I dont need it any more
(first step), and then i could reopen this same file and append something to
it. (When file was locked, restarting PC helps :o)) ...
You give me some reasonable explanation for this and then i will belive you
that setting a variable to nothing is rarely useful.
This way, i'm shure that my application will close immediate when i close
it, and will not stay in memory for next 5 minutes (waiting for GC to do
his
work) ...


Disposing of an object doesn't garbage collect it.


Yes, but as i readed somewhere GC will have less work.

Regards,
Josip Habjan
URL: http://www.habjansoftware.com
Jul 21 '05 #14
Josib,
May be, and may be not. Why?
Uisng FileStream .. i created new file, write something to it and then i
close it. I next step i tryed to open this same file to append something
to it, but this file was 'locked' from first step where i created it...
Why? Obviously some reference to this file is still hanginge somewhere in
the air!? I can only tell you that i tryed this fiew times and only thing
that helped is setting 'FileStream = Nothing' after I dont need it any
more (first step), and then i could reopen this same file and append
something to it. (When file was locked, restarting PC helps :o)) ...


Did you try this instead
http://msdn.microsoft.com/library/de...flushtopic.asp

You can also use the autoflush.

I hope this helps,

Cor
Jul 21 '05 #15
"Cor Ligthert" <no************@planet.nl> wrote in message
news:ec*************@TK2MSFTNGP15.phx.gbl...
Josib,
Did you try this instead
http://msdn.microsoft.com/library/de...flushtopic.asp

You can also use the autoflush.

I hope this helps,


hm.... as you can see 'filestream.close' will call 'filestream.flush' (you
dont need to call 'filestream.flush' if you call 'filestream.close')...
....and i always call 'filestream.close'.

Regards,
Josip Habjan
URL: http://www.habjansoftware.com
Jul 21 '05 #16
Josip Habjan <jh*****@spamoff-net.hr> wrote:
You can't call Dispose on most types though - there are plenty of types
which don't implement IDisposable.
I agree, but aso there are planty of types that does implements IDisposable.


Sure, but you said that you called Dispose on *every* object you create
except user controls, string, integer and related types.
Also note that setting a variable to nothing is rarely useful, IME.


May be, and may be not. Why?
Uisng FileStream .. i created new file, write something to it and then i
close it. I next step i tryed to open this same file to append something to
it, but this file was 'locked' from first step where i created it... Why?


I'd have to see the code, but it certainly sounds like you weren't
actually closing it properly.
Obviously some reference to this file is still hanginge somewhere in the
air!? I can only tell you that i tryed this fiew times and only thing that
helped is setting 'FileStream = Nothing' after I dont need it any more
(first step), and then i could reopen this same file and append something to
it. (When file was locked, restarting PC helps :o)) ...
You give me some reasonable explanation for this and then i will belive you
that setting a variable to nothing is rarely useful.


Under the debugger, it makes a difference in situations where you
aren't disposing properly. The correct solution is to call Dispose
appropriately.

The time it *does* make a difference is when it's a static or instance
variable, and you don't need the FileStream any more despite the rest
of the object living on. This tends to be a sign of poor design, IME.
This way, i'm shure that my application will close immediate when i close
it, and will not stay in memory for next 5 minutes (waiting for GC to do
his
work) ...


Disposing of an object doesn't garbage collect it.


Yes, but as i readed somewhere GC will have less work.


It means the finalizer doesn't need to be called, yes.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tim Bücker | last post by:
Following scenario: The user opens a form, a thread is started to play a sound ... public void playSoundUsingThread() { if (File.Exists(fileLocation)) PlaySound(fileLocation, 0, 0); //...
3
by: Saradhi | last post by:
Hi, I wanted to stop the VS.NET Window from closing inside my C# AddIn. I Know that OnBeginShutdown() funciton will be called whenever the user tries to close the VS.NET window. I want to...
6
by: John S | last post by:
When the user clicks the "X" in the upper right-hand corner of a form, how can I stop the form from closing?
4
by: SteveK | last post by:
Hi- I have created a basic login form. If the user enters invalid credentials, I want to display an error. However, when the user presses the Login button, the dialog closes... I'm sure this...
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
2
by: Bob Cummings | last post by:
Greetings I am sure this is a simple question. But I have "googled" it to death and have only found one answer that involved a bunch of window's API calls that I did not understand. I am a...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
16
by: ThunderMusic | last post by:
Hi, My app does not stop whan I click on the form. I mean, the form is closing, but the process keeps running in the task manager. So I figured there are memory leaks or some object's process...
1
by: JohnR | last post by:
I have a form that is presented in an mdi child window. If the user hits exit or the X button on the titlebar of the mdi child form, that form's "closing" event fires and in that event I check to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.