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

Submitter:  Marcus Urban <mathpup>
Submitted:  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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

No changes have been made to this item

Back to the top

Powered by Savane 3.13-758e.
Corresponding source code