473,382 Members | 1,647 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,382 software developers and data experts.

stop the GC

Hi there!

Is there any way how can I stop garbage collection for a period of time.

Lets say, I have a form. Before form load I pause the GC and when the form
is shown resume GC

Nov 15 '05 #1
12 2244
I don't think so.
What would happen if one app stops GC and never starts it again?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hi there!

Is there any way how can I stop garbage collection for a period of time.

Lets say, I have a form. Before form load I pause the GC and when the form
is shown resume GC

Nov 15 '05 #2
One app thats leaking alot of memory :D
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OP*************@TK2MSFTNGP12.phx.gbl...
I don't think so.
What would happen if one app stops GC and never starts it again?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hi there!

Is there any way how can I stop garbage collection for a period of time.

Lets say, I have a form. Before form load I pause the GC and when the form is shown resume GC


Nov 15 '05 #3
hmm, AFAIK Garbage Collector operates in the managed heap and every .NET app
has its own heap, so I can assume that every heap has its own collector.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OP*************@TK2MSFTNGP12.phx.gbl...
I don't think so.
What would happen if one app stops GC and never starts it again?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hi there!

Is there any way how can I stop garbage collection for a period of time.

Lets say, I have a form. Before form load I pause the GC and when the form is shown resume GC


Nov 15 '05 #4
Hi,

there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the garbage
collector need one ?
They are one and the same. If you are creating objects, memory comes from
the managed heap.
If you stop using those objects, the garbage collector reclaims this memory
(eventually).

BTW, why would you want to stop the garbage collector while creating the
form ?
Have you ever noticed the presence of the garbage collector (with regard to
performance, memory usage is another issue) ?

Greetings,

Bram.

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
hmm, AFAIK Garbage Collector operates in the managed heap and every .NET app has its own heap, so I can assume that every heap has its own collector.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OP*************@TK2MSFTNGP12.phx.gbl...
I don't think so.
What would happen if one app stops GC and never starts it again?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...
Hi there!

Is there any way how can I stop garbage collection for a period of time.
Lets say, I have a form. Before form load I pause the GC and when the form is shown resume GC



Nov 15 '05 #5
Hi Barn,
What do you mean "there is only one managed heap"?
What if two application run in different processes how do you expect them to
sare the same memory.
In a 32 bit machine a process can access 4GB flat address space. Normaly
windows application can use 2GB of them so if my all .NET application share
2GB or 4GB how many application can I run at the same time?
Of course using *file mapping* technique one can share a lot more memory
between precesses, but I don't thing this is the way GC works.
It might be (I'm not sure) that all application domains in the same process
to share the same managed heap. But it is for sure that not all .NET
application in the system share the same heap.

However for the original post; I don't thing you are able to stop the GC and
I don't see any reason to do that.
If you have any problems it might be something wrong with your application.
Would you give more information about your problem if you have any?
If you are concerned about performance don't be. IMHO GC is well optimized
and in normal conditions you shouldn't feel its exisitence.

B\rgds
100

"Bram" <bv*****@nospam.skynet.be> wrote in message
news:40**********************@news.skynet.be...
Hi,

there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the garbage collector need one ?
They are one and the same. If you are creating objects, memory comes from
the managed heap.
If you stop using those objects, the garbage collector reclaims this memory (eventually).

BTW, why would you want to stop the garbage collector while creating the
form ?
Have you ever noticed the presence of the garbage collector (with regard to performance, memory usage is another issue) ?

Greetings,

Bram.

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
hmm, AFAIK Garbage Collector operates in the managed heap and every .NET

app
has its own heap, so I can assume that every heap has its own collector.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OP*************@TK2MSFTNGP12.phx.gbl...
I don't think so.
What would happen if one app stops GC and never starts it again?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development miha at rthand com
www.rthand.com

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:e6*************@TK2MSFTNGP12.phx.gbl...
> Hi there!
>
> Is there any way how can I stop garbage collection for a period of time. >
> Lets say, I have a form. Before form load I pause the GC and when
the form
> is shown resume GC
>
>
>



Nov 15 '05 #6

My form involves great number of references, and the number of weak
references is rather big, so when the form is loading GC is also working
thus slowing down the form load process...
there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the garbage collector need one ?
They are one and the same. If you are creating objects, memory comes from
the managed heap.
If you stop using those objects, the garbage collector reclaims this memory (eventually).


AFAIK every .NET application starts CLR host, which resides in the windows
process. And therefore memory of this process is shared only for tha
appdomains in that process. I can hardly imagine the GC, that is looking in
the memory of other processes and builds the graph of objects currently in
the heap.
Nov 15 '05 #7
Hi,

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:uD**************@TK2MSFTNGP09.phx.gbl...
Hi Barn,
What do you mean "there is only one managed heap"?
I was referring to a single process. Every .NET application process has its
own and only one managed heap. Two different processes won't share the same
heap, as you also mentioned.
Two or more application domains will use the same heap, as memory is managed
and no single application can corrupt the heap and take all the other
applications down with it. That's how things might be in the future. If we
now launch a .NET application, a new .NET runtime engine is created to run
the app. That's why every (.NET) process takes at least 8 MB of memory or
even more. In the future, I guess, two or more applications might get
loaded into the same runtime engine (different domain though) when they (MS)
change the loader. This way they can share the framework assemblies to
preserve memory (a different way of code sharing). But that's all a guess.
Anybody real facts about this ?

Sorry for any confusion.
Greetings,

Bram.
What if two application run in different processes how do you expect them to sare the same memory.
In a 32 bit machine a process can access 4GB flat address space. Normaly
windows application can use 2GB of them so if my all .NET application share 2GB or 4GB how many application can I run at the same time?
Of course using *file mapping* technique one can share a lot more memory
between precesses, but I don't thing this is the way GC works.
It might be (I'm not sure) that all application domains in the same process to share the same managed heap. But it is for sure that not all .NET
application in the system share the same heap.

However for the original post; I don't thing you are able to stop the GC and I don't see any reason to do that.
If you have any problems it might be something wrong with your application. Would you give more information about your problem if you have any?
If you are concerned about performance don't be. IMHO GC is well optimized and in normal conditions you shouldn't feel its exisitence.

B\rgds
100

"Bram" <bv*****@nospam.skynet.be> wrote in message
news:40**********************@news.skynet.be...
Hi,

there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the

garbage
collector need one ?
They are one and the same. If you are creating objects, memory comes from
the managed heap.
If you stop using those objects, the garbage collector reclaims this

memory
(eventually).

BTW, why would you want to stop the garbage collector while creating the
form ?
Have you ever noticed the presence of the garbage collector (with regard

to
performance, memory usage is another issue) ?

Greetings,

Bram.

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
hmm, AFAIK Garbage Collector operates in the managed heap and every ..NET
app
has its own heap, so I can assume that every heap has its own

collector.
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OP*************@TK2MSFTNGP12.phx.gbl...
> I don't think so.
> What would happen if one app stops GC and never starts it again?
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & software

development > miha at rthand com
> www.rthand.com
>
> "Vadym Stetsyak" <pd****@ukr.net> wrote in message
> news:e6*************@TK2MSFTNGP12.phx.gbl...
> > Hi there!
> >
> > Is there any way how can I stop garbage collection for a period of

time.
> >
> > Lets say, I have a form. Before form load I pause the GC and when the form
> > is shown resume GC
> >
> >
> >
>
>



Nov 15 '05 #8
Hi,

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...

My form involves great number of references, and the number of weak
references is rather big, so when the form is loading GC is also working
thus slowing down the form load process...
Are you sure the GC is running when a form is being loaded ? Could be.
They might trigger a garbage collection when you are about to do something
intensive, like loading a form, so you don't notice the collection.
Brilliant cover up.
Don't think you'll ever notice the collector running, or not in any normal
application. Might be noticeable in some real-time applications which use a
lot of memory.
BTW, what is your memory usage when the form has been loaded ?

Greetings,

Bram
there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the garbage
collector need one ?
They are one and the same. If you are creating objects, memory comes from the managed heap.
If you stop using those objects, the garbage collector reclaims this

memory
(eventually).


AFAIK every .NET application starts CLR host, which resides in the windows
process. And therefore memory of this process is shared only for tha
appdomains in that process. I can hardly imagine the GC, that is looking

in the memory of other processes and builds the graph of objects currently in
the heap.

Nov 15 '05 #9
Hi Bram,
All application domains in the same process use the same mamory that is
true. Because they are managed (checked when compiled by the JITter) they
won't write in the memory addresses they are not supposed to write. However
it doesn't imply that they use the same managed heap as a structure. The
could use one heap of course. What I'm saing is that I haven't read
(actually I haven't ask my self that question) whether the heap is one or
each domain has its own. And I thing it is not important since application
domains cannot share memory.
Right now you cannot start two application in the same process using windows
loader, but you can start different application in the same process as a new
application domain from within the process (from application domain already
running in the process) Then they will share the same framework assemblies
because those assembies are loaded application neutral.

B\rgds
100

"Bram" <bv*****@nospam.skynet.be> wrote in message
news:40*********************@news.skynet.be...
Hi,

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:uD**************@TK2MSFTNGP09.phx.gbl...
Hi Barn,
What do you mean "there is only one managed heap"?
I was referring to a single process. Every .NET application process has

its own and only one managed heap. Two different processes won't share the same heap, as you also mentioned.
Two or more application domains will use the same heap, as memory is managed and no single application can corrupt the heap and take all the other
applications down with it. That's how things might be in the future. If we now launch a .NET application, a new .NET runtime engine is created to run
the app. That's why every (.NET) process takes at least 8 MB of memory or
even more. In the future, I guess, two or more applications might get
loaded into the same runtime engine (different domain though) when they (MS) change the loader. This way they can share the framework assemblies to
preserve memory (a different way of code sharing). But that's all a guess. Anybody real facts about this ?

Sorry for any confusion.
Greetings,

Bram.
What if two application run in different processes how do you expect them
to
sare the same memory.
In a 32 bit machine a process can access 4GB flat address space. Normaly
windows application can use 2GB of them so if my all .NET application

share
2GB or 4GB how many application can I run at the same time?
Of course using *file mapping* technique one can share a lot more memory
between precesses, but I don't thing this is the way GC works.
It might be (I'm not sure) that all application domains in the same

process
to share the same managed heap. But it is for sure that not all .NET
application in the system share the same heap.

However for the original post; I don't thing you are able to stop the GC

and
I don't see any reason to do that.
If you have any problems it might be something wrong with your

application.
Would you give more information about your problem if you have any?
If you are concerned about performance don't be. IMHO GC is well

optimized
and in normal conditions you shouldn't feel its exisitence.

B\rgds
100

"Bram" <bv*****@nospam.skynet.be> wrote in message
news:40**********************@news.skynet.be...
Hi,

there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the

garbage
collector need one ?
They are one and the same. If you are creating objects, memory comes from the managed heap.
If you stop using those objects, the garbage collector reclaims this

memory
(eventually).

BTW, why would you want to stop the garbage collector while creating the form ?
Have you ever noticed the presence of the garbage collector (with regard to
performance, memory usage is another issue) ?

Greetings,

Bram.

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
> hmm, AFAIK Garbage Collector operates in the managed heap and every .NET app
> has its own heap, so I can assume that every heap has its own collector. >
>
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:OP*************@TK2MSFTNGP12.phx.gbl...
> > I don't think so.
> > What would happen if one app stops GC and never starts it again?
> >
> > --
> > Miha Markic [MVP C#] - RightHand .NET consulting & software

development
> > miha at rthand com
> > www.rthand.com
> >
> > "Vadym Stetsyak" <pd****@ukr.net> wrote in message
> > news:e6*************@TK2MSFTNGP12.phx.gbl...
> > > Hi there!
> > >
> > > Is there any way how can I stop garbage collection for a period
of time.
> > >
> > > Lets say, I have a form. Before form load I pause the GC and

when the
> form
> > > is shown resume GC
> > >
> > >
> > >
> >
> >
>
>



Nov 15 '05 #10
I'm studying my application with the profiling tools, so there is no doubt
whos taking processor time.

Consumed memory is about 200 Mb.
Nov 15 '05 #11
real time in a managed environment, you must mean very very soft real time
:D
"Bram" <bv*****@nospam.skynet.be> wrote in message
news:40**********************@news.skynet.be...
Hi,

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...

My form involves great number of references, and the number of weak
references is rather big, so when the form is loading GC is also working
thus slowing down the form load process...
Are you sure the GC is running when a form is being loaded ? Could be.
They might trigger a garbage collection when you are about to do something
intensive, like loading a form, so you don't notice the collection.
Brilliant cover up.
Don't think you'll ever notice the collector running, or not in any normal
application. Might be noticeable in some real-time applications which use

a lot of memory.
BTW, what is your memory usage when the form has been loaded ?

Greetings,

Bram
there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the

garbage
collector need one ?
They are one and the same. If you are creating objects, memory comes from the managed heap.
If you stop using those objects, the garbage collector reclaims this

memory
(eventually).


AFAIK every .NET application starts CLR host, which resides in the windows process. And therefore memory of this process is shared only for tha
appdomains in that process. I can hardly imagine the GC, that is looking

in
the memory of other processes and builds the graph of objects currently in the heap.


Nov 15 '05 #12
Vadym,
This sounds like a place I would consider calling GC.Collect, followed by
GC.WaitForPendingFinalizers & a second GC.Collect before loading the form,
to help ensure that the heap was nice & clean, thus minimizing the chance
that the GC would need to do a collection while the form was loading.

Not sure if it will help per se, but its a thought ;-)
Also: Every thing you wanted to know about the GC but were afraid to ask:

http://msdn.microsoft.com/msdnmag/issues/1100/gci/
http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/

Hope this helps
Jay
Hope this helps
Jay

"Vadym Stetsyak" <pd****@ukr.net> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...

My form involves great number of references, and the number of weak
references is rather big, so when the form is loading GC is also working
thus slowing down the form load process...
there is only one managed heap AFAIK.
Ask yourself, if every application has it's own heap, why would the garbage
collector need one ?
They are one and the same. If you are creating objects, memory comes from the managed heap.
If you stop using those objects, the garbage collector reclaims this

memory
(eventually).


AFAIK every .NET application starts CLR host, which resides in the windows
process. And therefore memory of this process is shared only for tha
appdomains in that process. I can hardly imagine the GC, that is looking

in the memory of other processes and builds the graph of objects currently in
the heap.

Nov 15 '05 #13

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

Similar topics

2
by: engsol | last post by:
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss loves the quick turn-around compared to C). Each log file may contain one...
8
by: Eric Osman | last post by:
My javascript program has reason to want to stop. For example, function A has 5 lines, the second of which calls function B, which has 5 lines, the first of which calls function C. But...
5
by: Paul O. Morris | last post by:
Is there a script that I can run to stop a particular SQL server service on Win2003 server? I'm looking for a similar script to restart that service as well. Thanks.
2
by: Adrian MacNair | last post by:
Hi I need some help if anyone can understand my crap javascript. The problem is that after the slideshow ends (reaches the end of array) it should stop, but the timeout doesn't clear and I can see...
2
by: Prasad | last post by:
Hi, I am writing a service which takes a long time to stop after the OnStop call is given by the Services Snap-in. The problem is I cannot cut down on the time that it takes to Stop. The Service...
16
by: deko | last post by:
I have a sub routine that searches the Outlook PST for a message sent to/from a particular email address. Obviously, this can take a long time when the PST contains thousands of messages. I'd...
6
by: Jacobus Terhorst | last post by:
Using C#: I tried: ServiceController me = new ServiceController(this.ServiceName); me.Stop(); it raises an exception: Cannot find Service I also tried:
8
by: Matt Theule | last post by:
While stepping through an ASP.NET project, I found that data was being inserted into my database even though I was not stepping through the code that inserted the data. I have a single page with...
7
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch...
0
by: mattcfisher | last post by:
Hi, I have two windows services running together. One is the main program, and one is an "updater" wrapper for the main. The updater service starts and stops the main one (as in you should never...
1
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.