I use marshal_context in my clr C++ application to convert String^
while(i<10)
{
String^ message = gcnew String("Test String to Marshal");
marshal_context context;
const char* pch = context.marshal_as<const char*>(message);
/Functions that deal with pch pointer/
i++;
}
The above function is executed every time when data processing.
I create the dump file and find that the space assigned by the marshal_context always exists.
So, am I using it wrong?
Or, should I use it like following?
marshal_context^ context = gcnew marshal_context();
const char* pch = context->marshal_as<const char*>(message);
delete context;