[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ extension and garbage collection


I'm working on a DrScheme (plt-200aplha14) extension, written in C++.

It appears that DrScheme's garbage collection might be "collecting"
some of the extension's C++ objects.

Watching with gdb I can see that the C++ objects' fields are initialized
with non-zero values and that after DrScheme garbage collection runs, the
fields are zero.

Watching with gdb when the C++ objects are new'ed I see that DrScheme has
overridden the "new" operator and that this "new" operator is calling GC_malloc.

  (gdb) step
  __builtin_new (size=52) at ./../wxcommon/wxGC.cxx:46
  46        return GC_malloc(size);
  (gdb) step
  GC_malloc (lb=52) at malloc.c:284
  284         if( EXPECT(SMALL_OBJ(lb), 1) ) {
  Current language:  auto; currently c

>From wxcommon/wxGC.cxx

  void *operator new(size_t size)
  #ifdef USE_SENORA_GC
    if (!cpp_objects)
      cpp_objects = GC_new_set("C++", NULL, NULL, NULL, NULL, NULL, 0);

    return GC_malloc_specific(size, cpp_objects);
    return GC_malloc(size);

Shouldn't this "new" be calling GC_malloc_uncollectable?  Or is there some
other way I should be indicating to DrScheme to not collect the extension's
C++ objects?  Or have I built DrScheme incorrectly?