4

I am curious if any major projects have used Boehm GC? I'm particularly interested in if any gaming projects have used this garbage collector. If not, is Boehm GC bad for gaming projects?

I am impressed by the mere fact that simple code such as this Boehm GC can handle:

#include <stdio.h>
#include <stdlib.h>
#include <gc.h>

int main(void)
{
    int i;

    GC_INIT();
    for (i = 0; i < 10000000; ++i)
    {
        int *p = GC_MALLOC(sizeof(int *));
        //int *q = malloc(sizeof(int *));

        printf("Heap size = %d\n", GC_get_heap_size());
    }

    return 0;
}

Are there any caveats to making a game using Boehm GC?

Thanks

nobody
  • 61
  • 1
  • 1
    http://www.hpl.hp.com/personal/Hans_Boehm/gc/#users – Bart Jul 16 '11 at 22:20
  • I have seen that but that is of no interest to me. I am more interested in the gaming aspect of boehm-gc – nobody Jul 16 '11 at 22:23
  • Then you might want to rephrase your title. And no, I don't know of any games/game engines using this particular garbage collector. Although the concept itself is certainly applied in that domain. – Bart Jul 16 '11 at 22:35
  • Not sure why the downvote was warranted, guys, please, use it responsibly. – Thomas Dignan Jul 16 '11 at 22:40

1 Answers1

0

The Open Modelica Compiler (OMC) makes use of the Boehm GC. It is a very large application with over 300 000 lines of code and is used both in industry and in research. The garbage collector collects garbage during simulations.

See https://github.com/OpenModelica/OMCompiler/tree/master/SimulationRuntime/c/gc It defines the internal API for the garbage collector and might be a good reference and an interesting read.

However, if you are going to make a game in C++ I would recomend using smart pointers instead. If you really would like the comfort of having a garbage collector and you need to use C or C++ for some reason Boehm is a good option. Otherwise if performance is not critical for the game that you are programming, it might be wise to look at other languages with efficient garbage collectors such as Java or C#.

JKRT
  • 1,179
  • 12
  • 25