472,119 Members | 983 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Garbage Collection

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 measurement exactly 10 ms apart. In the
future this may decrease to 5ms ). I am concerned that if garbage
collection invokes during this time it may interfere with our measurement
results. I have looked over the garbage collection mechanism and see no way
to control when garbage collection occurs. Is there a way to pause and
start garbage collection? or some other technique that I can use to prevent
garbage collection while I am taking measurements?

Thanks

Bob
Nov 15 '05 #1
5 3329
I don't know how you can prevent the GC, but you can force the GC to
collect:
System.GC.Collect()

How are you measuring time spans?

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Bob lazarchik" <bo*****@yahoo.com> schreef in bericht
news:eN**************@TK2MSFTNGP11.phx.gbl...
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 measurement exactly 10 ms apart. In the
future this may decrease to 5ms ). I am concerned that if garbage
collection invokes during this time it may interfere with our measurement
results. I have looked over the garbage collection mechanism and see no way to control when garbage collection occurs. Is there a way to pause and
start garbage collection? or some other technique that I can use to prevent garbage collection while I am taking measurements?

Thanks

Bob

Nov 15 '05 #2
QueryPerformanceCounter

Bob
Nov 15 '05 #3
Bob,

It depends on what you mean by "precise". Windows in general doesn't make
timing guarantees, nor does the runtime, so I don't think you can do this
easily with a purely PC-based solution. Or, in other words, you can't do
"hard" real-time on Windows (and even soft real-time may take some work).
You might be able to get it to work (or make it close enough for your
application), but there are no guarantees on it continuing to work.

Can you do the sampling with hardware and then send it to a PC (or handheld)
over a serial link? That would give you buffering and make sure that you had
the samples at the right points.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://weblogs.asp.net/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
"Bob lazarchik" <bo*****@yahoo.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
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 measurement exactly 10 ms apart. In the
future this may decrease to 5ms ). I am concerned that if garbage
collection invokes during this time it may interfere with our measurement
results. I have looked over the garbage collection mechanism and see no way to control when garbage collection occurs. Is there a way to pause and
start garbage collection? or some other technique that I can use to prevent garbage collection while I am taking measurements?

Thanks

Bob

Nov 15 '05 #4
I may not be popular for suggesting this, but I'd recommend that you write
your measurement collection functions in unmanaged C++, and pass them into
the C# application for the rest of the work. You will get much better
control over timing.

If you are going to collect 1000 or 2000 measurements, and then stop
collecting, and then process data, you may be fine simply invoking garbage
collection at "safe" times (like before your data collection begins or after
it ends). On the other hand, if you collect your data using C# code, you
may have to have a way to prove that your measurements actually occurred at
10ms intervals, given that GC can occur at any time, and a plan for
collecting data again in the event that the first "measurement window" was
messed up by GC. IMHO, you are better off using unmanaged code for
fine-tune real-time measurements.

HTH,
--- Nick

"Bob lazarchik" <bo*****@yahoo.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
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 measurement exactly 10 ms apart. In the
future this may decrease to 5ms ). I am concerned that if garbage
collection invokes during this time it may interfere with our measurement
results. I have looked over the garbage collection mechanism and see no way to control when garbage collection occurs. Is there a way to pause and
start garbage collection? or some other technique that I can use to prevent garbage collection while I am taking measurements?

Thanks

Bob

Nov 15 '05 #5
In addition to caveats from other posters.

Bear in mind that Windows is not a hard real-time operating system. You may
be hard pressed to do 1000 measurements at exact 100ms intervals, let alone
10ms or worse still 5ms, even in a device driver written in assembler. The
basic time tick in Windows is 10ms or 15ms, so doing anything at intervals
shorter than that is almost doomed to failure, especially in a managed
language.

I think garbage collection will be the least of your worries.

Best Regards
Julian Nicholls

"Bob lazarchik" <bo*****@yahoo.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
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 measurement exactly 10 ms apart. In the
future this may decrease to 5ms ). I am concerned that if garbage
collection invokes during this time it may interfere with our measurement
results. I have looked over the garbage collection mechanism and see no way to control when garbage collection occurs. Is there a way to pause and
start garbage collection? or some other technique that I can use to prevent garbage collection while I am taking measurements?

Thanks

Bob

Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Ganesh | last post: by
11 posts views Thread by Rick | last post: by
34 posts views Thread by Ville Voipio | last post: by
8 posts views Thread by mike2036 | last post: by
28 posts views Thread by Goalie_Ca | last post: by
56 posts views Thread by Johnny E. Jensen | last post: by
350 posts views Thread by Lloyd Bonafide | last post: by
158 posts views Thread by pushpakulkar | last post: by
reply views Thread by leo001 | last post: by

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.