Real-time garbage collector

I am new to C # / Java and am planning a prototype of it for a soft real-time system.

If I wrote a C # / Java application in the same way as what I do in C ++ in terms of memory management, that is, I explicitly โ€œdeleteโ€ objects that I no longer use, will the application still be affected garbage collector? If so, how does this affect my application?

Sorry if this sounds like an obvious answer, but as a new one, I want to be solid.

+4
source share
6 answers

Take a look at IBM Metronome , the garbage collector for hard real-time systems.

+8
source

Your premise is incorrect: you cannot explicitly โ€œdeleteโ€ objects in Java or C #, so your application will always influence the GC.

You can try to call the collection by calling GC.Collect (C #) with the appropriate parameter (for example, GC.MaxGeneration ), but this still does not guarantee that the GC will not work at other times during execution.

+4
source

Explicitly "delete", if you mean releasing the reference to the object, you rely on the garbage collector in the managed C # code - see System. GC class for ways to manage it.

If you decide to write unmanaged C # code, then you will have more control over memory, akin to C ++, and it will be responsible for deleting your objects that can use pointers, etc. For more information, see the MSDN doc - Unsafe Code and Pointers (C # Programming Guide) .

In unmanaged code, you will not be at the mercy of the Garbage Collector and its vague cleanup algorithms.

I don't know if Java has equivalent unmanaged mode, but this Microsoft information can help in a certain direction in C # /. NET to use its available functions for your requirement to deal with the garbage collector.

+3
source

In Csharp or Java, you cannot delete an object. You can only mark them available for deletion. The memory will be freed by the garbage collector. The garbage collector may not work during the life of your application. However, it will most likely work. When your system runs out of resources, this is the most likely time that the GC routines start at run time. And when resources are low, GC becomes the highest priority thread. Thus, your application will be executed. However, you can minimize the effect by calculating the correct load and the required resources for your application lifetime and be sure to purchase the right equipment that is enough for this. But you cannot just evaluate your performance.

Besides just GC, a managed application does get a little overhead compared to a traditional C ++ application because of the extra delegation layer. And a small performance panel for the first time, since the startup time should be up and running before your application starts up.

+2
source

Here are some links for developing real-time systems with a compact .net card:

They both talk about memory requirements using the .net framework.

+1
source

C # and Java are not intended for real-time development. Soft real time is available, as you have noticed.

For C #, it is best to implement the finalize / dispose template implementation:

http://msdn.microsoft.com/en-us/library/b1yfkh5e(VS.71).aspx

You can request to collect it, but usually it is much better in determining how to do it.

http://msdn.microsoft.com/en-us/library/system.gc(VS.71).aspx

There are many optimization options for Java:

http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html

Along with third-party solutions such as IBM Metronome, as described above.

This is real science inside CS itself.

-one
source

All Articles