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 16 1879
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
ThunderMusic,
What do you mean with keeps running, all day long or a short time?
Cor
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
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
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
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
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
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
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
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
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
"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
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
"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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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); //...
|
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...
|
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?
|
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |