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

Goo on .NET update



I've looked into the garbage collection problem I was having earlier
and couldn't find an easy workaround. When returning memory allocated
from the CLR heap (that is, managed memory which is collectable) all
variable references using that memory must be tagged with '__gc'. Aside
from that, the code would need to be compiled using C++ (which wasn't a
problem, it compiles cleanly with a few grt.h changes) and you can't
cast from managed memory pointer to primitive types (ie. int). Goo does
this a lot as it uses tagging to identify object type (pointer,
integer, etc).

So I've compiled the Boehm collector as a DLL and use the Boehm
collector to allocate Goo objects (as the current Goo does now). Goo
still compiles and runs as a .NET application and can call .NET
classes. It just means there are two garbage collected heaps, the CLR
and the Boehm one.

I could not think of a nice way of getting around this need for two
collectors without doing major surgery to get the generated C code to
work with the restrictions imposed by Managed C++. I wasn't keen on
writing a C# or Managed C++ backend for g2c and I'm happy enough with
the ability to call .NET libraries and to be called by .NET.

Next steps would be to get dynamic compiling/loading working ala the
Linux version and some examples of calling .NET.

I'll post the updated package to my weblog [1] tonight with the current
changes that gets the GC working.

[1] http://radio.weblogs.com/0102385

Chris.
-- 
http://www.double.co.nz

-- 
  Chris Double
  chris.double@double.co.nz