Looking at the marshal.c code, this may be a problem in the runtime. We
allocate return strings using mono_marshal_alloc (evaluates to
CoTaskMemAlloc on Windows). However, we always free returned strings using
g_free on all platforms. I suppose we should use mono_marshal_free instead?
Please
[resending, email server not working]
On Thu, 2008-04-24 at 18:33 -0400, Miguel de Icaza wrote:
Hello,
The returned string is passed back to the SWIG C# class and used
(successfully) and then later the GC tries to collect it and fails.
The C# delegate is just something like
The GC does
Hi,
Ewen Cheslack-Postava wrote:
This seems to work well on Linux and Mac OS X, but on Windows it
causes an exception when the GC tries to free that same memory. I've
verified that I do in fact get a new copy of the string out at a
different address from the original. It looks like maybe
That's what's odd, I'm not even freeing the memory. Mono's GC is.
The call path goes something like:
My C code - mono_runtime_invoke - C# methods - SWIG C# class -
PInvoke call returning char* - C call to C# delegate - C# returns a
string
The returned string is passed back to the SWIG C# class
Hi,
I'm embedding Mono and using SWIG to wrap a few simple C++ objects.
They use PInvoke to wrap these objects and for string/char* return
values they use a C# delegate in order to obtain a string owned by the
GC so it can safely be returned. They use a simple C# static method
where the string