Hi all, lets get start.
i have a few questions to ask perhaps someone can help me.
i´m doing a simple aplication. some thing like this
i have a form with a button that opens another form in dialog mode.
' button code ...
Dim frm As New frmAbout
frm.ShowDialog(Me)
frm.Dispose()
first , when the application start, it uses (ex 17 mb of memory see using
the windows taskmanager), and after i close the dialog form, it uses even
more memory.
is there any sample that shows how realy gc works, i need to save memory not
spend an waiting for a stupid function todo his job.
second. when i use a form and open inside a function , the finaliza method
is never called. why ? see below ..
private sub Button1_click (...... )
Dim frm As New frmAbout
frm.ShowDialog(Me)
frm.Dispose()
end sub
i think it is suposed after the end sub, it calls the finalise of the
frmAbout ??? or It is'nt ?? the finalise is never called in this situation.
:(
what is microsoft thinking when they do the GC.
thks
JSB 8 1674
Hello, first , when the application start, it uses (ex 17 mb of memory see using the windows taskmanager), and after i close the dialog form, it uses even more memory.
Don't trust the taskmanager. Instead use either a CLR Profiler or check the
performance counter. second. when i use a form and open inside a function , the finaliza method is never called. why ? see below ..
By Finalizer you mean the destructor? That is not called when you call
dispose yourself.
Finalizers are very expensive, because the GC has to promote objects to
finalize to the next generation on the heap and run the finalizer. The
memory can only be reclaimed until the GC has run the next time.
Greetings,
Henning
"João Santa Bárbara" <jo****@i24portugal.com> wrote in message
news:OC****************@tk2msftngp13.phx.gbl... Hi all, lets get start.
i have a few questions to ask perhaps someone can help me. i´m doing a simple aplication. some thing like this i have a form with a button that opens another form in dialog mode.
' button code ... Dim frm As New frmAbout frm.ShowDialog(Me) frm.Dispose()
first , when the application start, it uses (ex 17 mb of memory see using the windows taskmanager), and after i close the dialog form, it uses even more memory. is there any sample that shows how realy gc works, i need to save memory not spend an waiting for a stupid function todo his job.
' button code ...
Dim frm As New frmAbout
frm.ShowDialog(Me)
frm.Dispose()
frm = nothing
gc.Collect()
This will reduce the memory. In a fat client application, when you _know_
that the managed heap is mostly garbage, and you want to keep it from
getting any bigger, feel free to force a garbage collection.
David
check out Rico's blog, this guy knows what he is talking about.... http://blogs.msdn.com/ricom/archive/...29/271829.aspx
HTH
Ollie Riches
"João Santa Bárbara" <jo****@i24portugal.com> wrote in message
news:OC**************@tk2msftngp13.phx.gbl... Hi all, lets get start.
i have a few questions to ask perhaps someone can help me. i´m doing a simple aplication. some thing like this i have a form with a button that opens another form in dialog mode.
' button code ... Dim frm As New frmAbout frm.ShowDialog(Me) frm.Dispose()
first , when the application start, it uses (ex 17 mb of memory see using the windows taskmanager), and after i close the dialog form, it uses even more memory. is there any sample that shows how realy gc works, i need to save memory
not spend an waiting for a stupid function todo his job.
second. when i use a form and open inside a function , the finaliza method is never called. why ? see below ..
private sub Button1_click (...... ) Dim frm As New frmAbout frm.ShowDialog(Me) frm.Dispose() end sub
i think it is suposed after the end sub, it calls the finalise of the frmAbout ??? or It is'nt ?? the finalise is never called in this
situation. :( what is microsoft thinking when they do the GC.
thks JSB
Henning,
Are you sure that destructors are not called when you call a Dispose
yourself. I think this is done only when you GC.SuppressFinalize() from the
Dispose method that this happens.
-- http://dotnetjunkies.com/weblog/dotnut
"Henning Krause [MVP]" <ne**********@spam.infinitec.de> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl... Hello,
first , when the application start, it uses (ex 17 mb of memory see
using the windows taskmanager), and after i close the dialog form, it uses
even more memory. Don't trust the taskmanager. Instead use either a CLR Profiler or check
the performance counter.
second. when i use a form and open inside a function , the finaliza
method is never called. why ? see below ..
By Finalizer you mean the destructor? That is not called when you call dispose yourself.
Finalizers are very expensive, because the GC has to promote objects to finalize to the next generation on the heap and run the finalizer. The memory can only be reclaimed until the GC has run the next time.
Greetings, Henning
"Ranjan" <ra*************@gmail.com> wrote in message
news:O2**************@TK2MSFTNGP14.phx.gbl... Henning, Are you sure that destructors are not called when you call a Dispose yourself. I think this is done only when you GC.SuppressFinalize() from the Dispose method that this happens.
A destructor is not called when a Dispose method is called - internally in
..NET they have nothing to do with each other.
When an object is no longer reachable via a root and a garbage collection
cycle occurs, the GC determines that the object has a finalizer and puts the
object on a special finalizer queue. This is serviced by a thread that runs
in the background. After the finalizer for the object has run and the next
GC cycle has occurred the memory is reclaimed.
When a Dispose method is called all that happens is that a method (called
Dispose) is invoked on the object; the intent of this method is to cleanup
the object (whatever that means). It does not involve the finalizer at all.
Typically after an object has been disposed it should not be used again -
however, this is not a requirement, it is a convention.
Quite often the Dispose method also calls GC.SuppressFinalize(). This has
the effect of removing the object from the list of objects that require
finalization so that the extra GC cycle to reclaim the memory does not
occur. However, calling GC.SuppressFinalize() from the Dispose method is not
done by the CLR, nor is it a requirement, it is only a convention that most
programmers follow.
For example, if a Dispose is called on an object but GC.SuppressFinalize()
is not called, and the object remains reachable, then the Finalizer is never
called and the memory is never reclaimed. Conversely, if the object is no
longer reachable then at the next GC cycle the Finalizer gets queued, and on
the following GC it is called, even if the Dispose method is never called.
This proves that the two operations are unrelated unless specifically tied
together via user logic.
-- http://dotnetjunkies.com/weblog/dotnut "Henning Krause [MVP]" <ne**********@spam.infinitec.de> wrote in message news:Ov**************@TK2MSFTNGP10.phx.gbl... Hello,
> first , when the application start, it uses (ex 17 mb of memory see using > the windows taskmanager), and after i close the dialog form, it uses even > more memory.
Don't trust the taskmanager. Instead use either a CLR Profiler or check the performance counter.
> > second. when i use a form and open inside a function , the finaliza method > is never called. why ? see below .. >
By Finalizer you mean the destructor? That is not called when you call dispose yourself.
Finalizers are very expensive, because the GC has to promote objects to finalize to the next generation on the heap and run the finalizer. The memory can only be reclaimed until the GC has run the next time.
Greetings, Henning
Exactly my thoughts
-- http://dotnetjunkies.com/weblog/dotnut
"David Levine" <no******************@wi.rr.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl... "Ranjan" <ra*************@gmail.com> wrote in message news:O2**************@TK2MSFTNGP14.phx.gbl... Henning, Are you sure that destructors are not called when you call a Dispose yourself. I think this is done only when you GC.SuppressFinalize() from the Dispose method that this happens. A destructor is not called when a Dispose method is called - internally in .NET they have nothing to do with each other.
When an object is no longer reachable via a root and a garbage collection cycle occurs, the GC determines that the object has a finalizer and puts
the object on a special finalizer queue. This is serviced by a thread that
runs in the background. After the finalizer for the object has run and the next GC cycle has occurred the memory is reclaimed.
When a Dispose method is called all that happens is that a method (called Dispose) is invoked on the object; the intent of this method is to cleanup the object (whatever that means). It does not involve the finalizer at
all. Typically after an object has been disposed it should not be used again - however, this is not a requirement, it is a convention.
Quite often the Dispose method also calls GC.SuppressFinalize(). This has the effect of removing the object from the list of objects that require finalization so that the extra GC cycle to reclaim the memory does not occur. However, calling GC.SuppressFinalize() from the Dispose method is
not done by the CLR, nor is it a requirement, it is only a convention that
most programmers follow.
For example, if a Dispose is called on an object but GC.SuppressFinalize() is not called, and the object remains reachable, then the Finalizer is
never called and the memory is never reclaimed. Conversely, if the object is no longer reachable then at the next GC cycle the Finalizer gets queued, and
on the following GC it is called, even if the Dispose method is never called.
This proves that the two operations are unrelated unless specifically tied together via user logic.
-- http://dotnetjunkies.com/weblog/dotnut "Henning Krause [MVP]" <ne**********@spam.infinitec.de> wrote in message news:Ov**************@TK2MSFTNGP10.phx.gbl... Hello,
> first , when the application start, it uses (ex 17 mb of memory see using > the windows taskmanager), and after i close the dialog form, it uses even > more memory.
Don't trust the taskmanager. Instead use either a CLR Profiler or check the performance counter.
> > second. when i use a form and open inside a function , the finaliza method > is never called. why ? see below .. >
By Finalizer you mean the destructor? That is not called when you call dispose yourself.
Finalizers are very expensive, because the GC has to promote objects to finalize to the next generation on the heap and run the finalizer. The memory can only be reclaimed until the GC has run the next time.
Greetings, Henning
I got the context wrong it think.
What Henning wrote was it is not inherent that a destructor is called when a
Dispose is called.
I misunderstood, misread the "not" part. Sorry.
--
"Ranjan" <ra*************@gmail.com> wrote in message
news:Og**************@tk2msftngp13.phx.gbl... Exactly my thoughts
-- http://dotnetjunkies.com/weblog/dotnut
"David Levine" <no******************@wi.rr.com> wrote in message news:uh**************@TK2MSFTNGP12.phx.gbl... "Ranjan" <ra*************@gmail.com> wrote in message news:O2**************@TK2MSFTNGP14.phx.gbl... Henning, Are you sure that destructors are not called when you call a
Dispose yourself. I think this is done only when you GC.SuppressFinalize()
from the Dispose method that this happens. A destructor is not called when a Dispose method is called - internally
in .NET they have nothing to do with each other.
When an object is no longer reachable via a root and a garbage
collection cycle occurs, the GC determines that the object has a finalizer and puts the object on a special finalizer queue. This is serviced by a thread that runs in the background. After the finalizer for the object has run and the
next GC cycle has occurred the memory is reclaimed.
When a Dispose method is called all that happens is that a method
(called Dispose) is invoked on the object; the intent of this method is to
cleanup the object (whatever that means). It does not involve the finalizer at all. Typically after an object has been disposed it should not be used
again - however, this is not a requirement, it is a convention.
Quite often the Dispose method also calls GC.SuppressFinalize(). This
has the effect of removing the object from the list of objects that require finalization so that the extra GC cycle to reclaim the memory does not occur. However, calling GC.SuppressFinalize() from the Dispose method is not done by the CLR, nor is it a requirement, it is only a convention that most programmers follow.
For example, if a Dispose is called on an object but
GC.SuppressFinalize() is not called, and the object remains reachable, then the Finalizer is never called and the memory is never reclaimed. Conversely, if the object is
no longer reachable then at the next GC cycle the Finalizer gets queued,
and on the following GC it is called, even if the Dispose method is never
called. This proves that the two operations are unrelated unless specifically
tied together via user logic.
-- http://dotnetjunkies.com/weblog/dotnut "Henning Krause [MVP]" <ne**********@spam.infinitec.de> wrote in
message news:Ov**************@TK2MSFTNGP10.phx.gbl... > Hello, > > > first , when the application start, it uses (ex 17 mb of memory
see using > > the windows taskmanager), and after i close the dialog form, it
uses even > > more memory. > > Don't trust the taskmanager. Instead use either a CLR Profiler or
check the > performance counter. > > > > > second. when i use a form and open inside a function , the finaliza method > > is never called. why ? see below .. > > > > By Finalizer you mean the destructor? That is not called when you
call> dispose yourself. > > Finalizers are very expensive, because the GC has to promote objects
to> finalize to the next generation on the heap and run the finalizer.
The> memory can only be reclaimed until the GC has run the next time. > > > Greetings, > Henning > >
Yes, thats right. But most Dipose() method make a call to
SuppressFinalize().
Greetings,
Henning Krause [MVP]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
( http://www.infinitec.de/software/mistaya.aspx)
"Ranjan" <ra*************@gmail.com> wrote in message
news:O2**************@TK2MSFTNGP14.phx.gbl... Henning, Are you sure that destructors are not called when you call a Dispose yourself. I think this is done only when you GC.SuppressFinalize() from
the Dispose method that this happens. -- http://dotnetjunkies.com/weblog/dotnut "Henning Krause [MVP]" <ne**********@spam.infinitec.de> wrote in message news:Ov**************@TK2MSFTNGP10.phx.gbl... Hello,
first , when the application start, it uses (ex 17 mb of memory see using the windows taskmanager), and after i close the dialog form, it uses even more memory.
Don't trust the taskmanager. Instead use either a CLR Profiler or check the performance counter.
second. when i use a form and open inside a function , the finaliza method is never called. why ? see below ..
By Finalizer you mean the destructor? That is not called when you call dispose yourself.
Finalizers are very expensive, because the GC has to promote objects to finalize to the next generation on the heap and run the finalizer. The memory can only be reclaimed until the GC has run the next time.
Greetings, Henning
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bob |
last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and...
|
by: Ganesh |
last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a
process without have access to the process code.
regards
Ganesh
|
by: Rick |
last post by:
Hi,
My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language? Are there fundamental reasons behind...
|
by: Ville Voipio |
last post by:
I would need to make some high-reliability software
running on Linux in an embedded system. Performance
(or lack of it) is not an issue, reliability is.
The piece of software is rather simple,...
|
by: Bob lazarchik |
last post by:
Hello:
We are considering developing a time critical system in C#. Our tool used in
Semiconductor production and we need to be able to take meaurements at
precise 10.0 ms intervals( 1000...
|
by: mike2036 |
last post by:
For some reason it appears that garbage collection is releasing an object
that I'm still using. The object is declared in a module and instantiated
within a class that is in turn instantiated by...
|
by: Goalie_Ca |
last post by:
I have been reading (or at least googling) about the potential addition
of optional garbage collection to C++0x. There are numerous myths and
whatnot with very little detailed information.
Will...
|
by: Johnny E. Jensen |
last post by:
Hellow
I'am not sure what to think about the Garbage Collector.
I have a Class OutlookObject, It have two private variables.
Private Microsoft.Office.Interop.Outlook.Application _Application =...
|
by: Lloyd Bonafide |
last post by:
I followed a link to James Kanze's web site in another thread and was
surprised to read this comment by a link to a GC:
"I can't imagine writing C++ without it"
How many of you c.l.c++'ers use...
|
by: pushpakulkar |
last post by:
Hi all,
Is garbage collection possible in C++. It doesn't come as part of
language support. Is there any specific reason for the same due to the
way the language is designed. Or it is...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |