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

Garbage collection and soft real-time apps

Before I get into the question -- I know .NET isn't the right solution for
this app but it's part of my clients requirements and writing this in C++
isn't an option. That being said -- my app is a stock ticker using the
managed DirectX libraries and the animation needs to be perfectly smooth.
Problem is that the garbage collector will kick in from time to time and
cause my render thread to miss a frame and makes it look like hell (even at
75 hz it's quite noticeable).

Is there any way to prevent managed code to not block on garbage collection?
I know this generally isn't a good idea but all my render thread is doing is
calling Device.Present -- all the other threads aren't critical and can be
suspended. Any ideas would be greatly appreciated.
Jul 21 '05 #1
2 1718

"Oculus" <Oc****@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
Before I get into the question -- I know .NET isn't the right solution for
this app but it's part of my clients requirements and writing this in C++
isn't an option. That being said -- my app is a stock ticker using the
managed DirectX libraries and the animation needs to be perfectly smooth.
Problem is that the garbage collector will kick in from time to time and
cause my render thread to miss a frame and makes it look like hell (even
at
75 hz it's quite noticeable).

Is there any way to prevent managed code to not block on garbage
collection?
I know this generally isn't a good idea but all my render thread is doing
is
calling Device.Present -- all the other threads aren't critical and can be
suspended. Any ideas would be greatly appreciated.


I think the best you can do is minimize the impact of garbage collection
using a two-pronged approach.

First thing is to work hard to produce less garbage. The less garbage you
produce, the cheaper and less frequent collections are. Using structs,
pooling objects, minimizing string allocations, and reusing buffers can
dramatically reduce the amount of garbage generated by your application.

Second is be to collect on your own schedule. When you know there is
garbage and you have some time, force a collection. In a winforms app where
your appliction owns the whole process and all of the memory allocations,
you can figure out when and where to collect better than the garbage
collector. For a general purpose application it's not worth the trouble,
but when you can't afford those little pauses it can be.

David
Jul 21 '05 #2
Thanks,

We've actually done both of those things and really pared down our throwaway
objects. Still, a generation 0 garbage collection can take over 15ms which
is about all the time I have to swap backbuffers (we're pre-rendering
backbuffers to help alleviate the problem).

"David Browne" wrote:

"Oculus" <Oc****@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
Before I get into the question -- I know .NET isn't the right solution for
this app but it's part of my clients requirements and writing this in C++
isn't an option. That being said -- my app is a stock ticker using the
managed DirectX libraries and the animation needs to be perfectly smooth.
Problem is that the garbage collector will kick in from time to time and
cause my render thread to miss a frame and makes it look like hell (even
at
75 hz it's quite noticeable).

Is there any way to prevent managed code to not block on garbage
collection?
I know this generally isn't a good idea but all my render thread is doing
is
calling Device.Present -- all the other threads aren't critical and can be
suspended. Any ideas would be greatly appreciated.


I think the best you can do is minimize the impact of garbage collection
using a two-pronged approach.

First thing is to work hard to produce less garbage. The less garbage you
produce, the cheaper and less frequent collections are. Using structs,
pooling objects, minimizing string allocations, and reusing buffers can
dramatically reduce the amount of garbage generated by your application.

Second is be to collect on your own schedule. When you know there is
garbage and you have some time, force a collection. In a winforms app where
your appliction owns the whole process and all of the memory allocations,
you can figure out when and where to collect better than the garbage
collector. For a general purpose application it's not worth the trouble,
but when you can't afford those little pauses it can be.

David

Jul 21 '05 #3

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

Similar topics

3
by: Thomas Mailund | last post by:
Hi group. I have a problem with some C extensions I am working with and hope that some of you can help. Basically, I am wrapping a a tree structure from C where I have python methods for...
34
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,...
55
by: jacob navia | last post by:
Tired of chasing free(tm) bugs? Get serious about C and use lcc-win32. The garbage collector designed by Boehm is the best of its class. Very simple: #define malloc GC_malloc #define free(a)...
5
by: R. MacDonald | last post by:
Hello, all, I am currently working on a .Net (VB) application that invokes routines in unmanaged (Fortran) DLLs. The unmanaged routines then communicate with the .Net application by means of a...
4
by: klar02 | last post by:
We have a web server with 2GB of physical memory on it and we are seeing the memory usage running over 800,000KB in Task Manager. We have seen instances where the memory being this high(due to...
142
by: jacob navia | last post by:
Abstract -------- Garbage collection is a method of managing memory by using a "collector" library. Periodically, or triggered by an allocation request, the collector looks for unused memory...
2
by: roger.dunham | last post by:
I am trying to identify whether a .NET 1.1 application that I have written has a memory leak. I thought I understood how .NET memory management worked, but it appears that there is more to it...
56
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 =...
72
by: Sebastian Nibisz | last post by:
SGCL is precise, parallel garbage collection library for C++ (at this time for Windows 32/64 only). SGCL is free software published under University of Illinois/NCSA Open Source License. Get it...
158
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...
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
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.