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

 
 

You are not allowed to post comments on this tracker with your current authentification 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: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned 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 click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup