bugDotGNU Portable.NET - Bugs: bug #9086, Marshaled memory management...


You are not allowed to post comments on this tracker with your current authentication level.

bug #9086: Marshaled memory management differs from .NET

Submitted by:  Marcus Urban <mathpup>
Submitted on:  Tue 25 May 2004 12:16:28 AM UTC  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Sat 19 Jun 2004 05:11:07 AM UTC, comment #1:

Well strings returned from unmanaged code will be automatically freed now.

Not sure about the other stuff yet...

Thong Nguyen <tum>
Project Member
Tue 25 May 2004 12:16:28 AM UTC, original submission:

The memory management conventions used when marshaling parameters and return types in P/Invoke appear to differ from those described and implemented in .NET.

Specifically, when .NET marshals a class or string and passes to pass to unmanaged code, the runtime creates a temporary copy of the data and passes a pointer to the temporary data. Once the unmanaged method returns, the .NET runtime frees the temporary data. The Pnet runtime does not seem to free the temporary storage. The result is that a programming might find that his program works on Pnet but not Mono or .NET.

A similar situation occurs with return values, especially strings. When a P/Invoke method returns a string, .NET attempts to free the string.

(Yes, the conventions described here are sometimes inconvenient for interop. For example, if a C function returns a pointer to a static string buffer that should not be freed, the default marshaling for string is not acceptable, and the programmer must use IntPtr for the return type and marshal the data manually.)

Marcus Urban <mathpup>


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


CC list is empty


Do you think this task is very important?
If so, you can add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.




No changes have been made to this item

Back to the top

Powered by Savane 3.3