Deterministic GC in the CLR?

自闭症网瘾萝莉.ら 提交于 2019-12-13 13:15:22

问题


are there any CLR implementations that have deterministic garbage collection?

Nondeterministic pauses in the MS CLR GC inhibit .Net from being a suitable environment for real-time development.

Metronome GC and BEA JRockit in Java are two deterministic GC implementations that I'm aware of.

But have there any .Net equivalents?

Thanks


回答1:


There is no way to make the GC deterministic, expect of course from calling GC.Collect() exactly every second using a timer ;-).

The GC however does contain a notification mechanism (since .NET 3.5 SP1) that allows you to be notified when a gen 2 collect is about to happen. You can read about it here.

The GC now also contains multiple latency modes that make it possible to prevent any GC collects from occurring. Of course you should be very careful with this, but is especially useful for real-time systems. You can read more about it here.




回答2:


No, there are non. From my experience .net can't be used to create real time systems for many reasons, not only about garbage collection. C or C++ are better choice. Also modern OSes do not provide deterministic scheduling, and it is about all applications, regardless of language.




回答3:


You would have to control the GC yourself in order to get predictable real-time behaviour, but if you are doing this then you may as well not use a managed language.

For real-time systems you need control over everything that is running. There are third-party modifications to Windows XP that make it real-time (can't remember if it's soft or hard real-time though).

Completely unfeasible option. Look into Cosmos OS - written in C# and compiled to assembler I think - might be able to do something with that :)



来源:https://stackoverflow.com/questions/3165201/deterministic-gc-in-the-clr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!