How can I determine when a GC should work?

I am writing a statically compiled language and I would like to support garbage collection. Before designing it, I would like to know how should I deduce when the GC should work?

Should this be after every 16-month interval allocation? (check after a sufficient increase or only before he allocates 16 + mb). Is there any way to check the Euler so that loops can reuse the same memory in order to be efficient? etc.

+3
source share
1 answer

The best time to start the GC is "when the program has some time left". For example, if you have a run loop and no event has been queued, this might be the right time to start the GC. And then, perhaps, also, if the GC allocator notices that it will need to request the OS for more memory. I think it also depends on the design of the GC, for example. It is possible to create a GC that starts in its thread and does not interrupt the program compared to the usual GC "stop the world".

The question is also, do you want to implement the GC for training only? Or do you just want a GC? In a later case, I suggest you take a peek at GC Boehm.

+2
source

Source: https://habr.com/ru/post/1767661/


All Articles