Does marshal_context cause memory leaks?

Aspire 81 Reputation points
2020-07-03T12:00:03.66+00:00

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;

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,757 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 32,731 Reputation points Microsoft Vendor
    2020-07-06T03:39:00.397+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Currently, Microsoft Q&A supports the products listed over here: supported topics (more to be added later on).

    Your question about clr C++ appliction is not supported yet now. You could ask about this in Visual C++ forum.

    Thank you.

    0 comments No comments