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

how can I disable GC for a third of a second

I have a tight time constraint on a small chunk of processing. It
takes about a third of a second to run. Occasionally, this function
will get stalled for (what I can only guess) is a garbage collection
(GC) run. Is there any way I can disable the GC for that brief third
of a second?

Aug 22 '07 #1
4 2592
You can't. And to be honest, if this is a requirement, then .NET isn't
a platform you should be doing this work in. You should do it in an
unmanaged piece of code, like C++.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"not_a_commie" <no********@gmail.comwrote in message
news:11*********************@e9g2000prf.googlegrou ps.com...
>I have a tight time constraint on a small chunk of processing. It
takes about a third of a second to run. Occasionally, this function
will get stalled for (what I can only guess) is a garbage collection
(GC) run. Is there any way I can disable the GC for that brief third
of a second?

Aug 22 '07 #2
Are you sure it is the GC kicking in? Is your process attempt to access any
files, databases etc, because if it is these could be causing your random
stall. Also IMO a third of a second is an age for any computer.

If you search on Google you will find lots of good articles about garbage
collection in .Net - all the articles will tell you that garbage collection
is non deterministic, you can't predict or determine when it will run and you
can't control in the manner you require. What can be said about garbage
collection is that it will only run when system resources become scarce, i.e.
when the amount of memory available for the process starts to run low it will
attempt to free any unwanted memory.

If it is GC causing the stall then you need to analyse your application from
memory point of view, as in what objects are being created, are they being
used efficiently and disposed of correctly etc. This won't remove the
possibility completely that the GC will run during your critical phase but it
can reduce it.

HTH

Ollie Riches

"not_a_commie" wrote:
I have a tight time constraint on a small chunk of processing. It
takes about a third of a second to run. Occasionally, this function
will get stalled for (what I can only guess) is a garbage collection
(GC) run. Is there any way I can disable the GC for that brief third
of a second?

Aug 22 '07 #3
I would only add that under heavy CPU usage, the GC generally won't run.
I've had apps that wouldn't GC because the CPU was pegged and I've had to
force GC periodically to avoid paging problems.

I suspect if it's happening regularly for that piece of code, it likely
isn't the GC, but something else. You might try downloading nProf (a free
open source .NET profiler,
http://www.mertner.com/confluence/display/NProf/Home) and running your code
under that to see what's using up the time. I've found it extremely helpful.

"Ollie" <ol**********@hotmail.comwrote in message
news:0E**********************************@microsof t.com...
Are you sure it is the GC kicking in? Is your process attempt to access
any
files, databases etc, because if it is these could be causing your random
stall. Also IMO a third of a second is an age for any computer.

If you search on Google you will find lots of good articles about garbage
collection in .Net - all the articles will tell you that garbage
collection
is non deterministic, you can't predict or determine when it will run and
you
can't control in the manner you require. What can be said about garbage
collection is that it will only run when system resources become scarce,
i.e.
when the amount of memory available for the process starts to run low it
will
attempt to free any unwanted memory.

If it is GC causing the stall then you need to analyse your application
from
memory point of view, as in what objects are being created, are they being
used efficiently and disposed of correctly etc. This won't remove the
possibility completely that the GC will run during your critical phase but
it
can reduce it.

HTH

Ollie Riches

"not_a_commie" wrote:
>I have a tight time constraint on a small chunk of processing. It
takes about a third of a second to run. Occasionally, this function
will get stalled for (what I can only guess) is a garbage collection
(GC) run. Is there any way I can disable the GC for that brief third
of a second?


Aug 22 '07 #4

"not_a_commie" <no********@gmail.comwrote in message
news:11*********************@e9g2000prf.googlegrou ps.com...
>I have a tight time constraint on a small chunk of processing. It
takes about a third of a second to run. Occasionally, this function
will get stalled for (what I can only guess) is a garbage collection
(GC) run. Is there any way I can disable the GC for that brief third
of a second?
If you run the GC before starting that processing, it's extremely unlikely
that you would need the GC again in such a short time.
Aug 22 '07 #5

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

Similar topics

30
by: Blnukem | last post by:
Hi All I'm new to javascript and was wondering if someone can help me with this I want to disable my second and third drop-box if the first one is selected to "Closed" I think I'm close but just...
1
by: Fluffy Convict | last post by:
Does anybody know how to disable only certain options of an option list by a javascript function? With the following function you can disable a option list completely: function disableList() {...
4
by: Quatney | last post by:
Okay, I'm going nuts here. I know this is VERY easy and I shouldn't have problems with this, but I can't seem to figure out what I want to do. I have a form, with two drop down boxes. I want...
29
by: lori3laz | last post by:
How do you disable the right click>view source option on web pages so people can't view your coding and copy it? What's the html I need to include in my website to utilize this feature? Thank...
14
by: Sinity | last post by:
Anyone knows the method/codes to disable the clicked button after first click by using .aspx-- to prevent people to click many time when waiting for the server response. I tried to do this by...
8
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code...
3
by: zhang.yongpeng | last post by:
Hello, I met some problems when trying to sort a list that has shared_ptr in it. here is the non-compliable code. test.cpp: /********************* begin of code *************************/...
6
by: =?Utf-8?B?TWljaGFlbCAwMw==?= | last post by:
I need to disable the clipboard function in Windows XP. We are having a problem with users using CTRL+C in one program, then using CTRL+V in another. Specifically, they type their password into...
3
by: Grizlyk | last post by:
Hello. I am thinking: why if i will comment lines marked with '#' in the following example, all will be compiled, else will not: // *********************** typedef unsigned uint; ...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.