[Mono-bugs] [Bug 42316][Nor] Changed - The runtime does not free strings passed to P/Invoked functions

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Mon, 5 May 2003 19:00:57 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by gonzalo@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=42316

--- shadow/42316	Mon May  5 00:48:19 2003
+++ shadow/42316.tmp.27828	Mon May  5 19:00:57 2003
@@ -1,23 +1,23 @@
 Bug#: 42316
-Product: Mono/Class Libraries
+Product: Mono/Runtime
 Version: unspecified
 OS: All
 OS Details: 
 Status: NEW   
 Resolution: 
 Severity: Unknown
 Priority: Normal
-Component: System.XML
+Component: misc
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: bmaurer@users.sf.net               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: System.Xml.Xsl has major memory leaks
+Summary: The runtime does not free strings passed to P/Invoked functions
 
 Description of Problem:
 Code in the namespce System.Xml.Xsl does not free some of the memory it
 allocates. 
 
 Steps to reproduce the problem:
@@ -35,6 +35,36 @@
 Always.
 
 Additional Information:
 
 ------- Additional Comments From gonzalo@ximian.com  2003-05-05 00:48 -------
 I'd like to have a small test case attached to the bug, but, well...
+
+------- Additional Comments From gonzalo@ximian.com  2003-05-05 19:00 -------
+This is in fact a problem of the runtime.
+
+See this program:
+-----
+using System;
+using System.Threading;
+using System.Runtime.InteropServices;
+
+class C
+{
+	[DllImport ("glib-2.0")]
+	extern static void g_print (string msg);
+
+	static void Main ()
+	{
+		for (int i = 0; i < 10000; i++)
+			g_print ("Hi there!\n");
+
+		Thread.Sleep (1000000);
+	}
+}
+------
+
+The Sleep is there to allow memprof to display the leaks. All of them
+come from mono_string_to_utf8 allocated strings that are passed to
+g_print in this case.
+
+They should be freed.