Is a garbage collector (.net/java) an issue for real-time systems?

前端 未结 7 1406
灰色年华
灰色年华 2021-02-01 03:19

When building a system which needs to respond very consistently and fast, is having a garbage collector a potential problem?

I remember horror stories from years ago whe

7条回答
  •  梦如初夏
    2021-02-01 04:09

    Yes, garbage must be handled in a deterministic manner in real-time systems.

    One approach is to schedule a certain amount of garbage collection time during each memory allocation. This is called "work-based garbage collection." The idea is that in the absence of leaks, allocation and collection should be proportional.

    Another simple approach ("time-based garbage collection") is to schedule a certain proportion of time for periodic garbage collection, whether it is needed or not.

    In either case, it is possible that a program will run out of usable memory because it is not allowed to spend enough time to do a full garbage collection. This is in contrast to a non-realtime system, which is permitted to pause as long as it needs to in order to collect garbage.

提交回复
热议问题