[mono-android] Persistent issues with GC Collect killing my xml serialization

devbuzz derek at fieldmetrix.com
Wed Feb 29 21:35:18 UTC 2012


I'm having a persistent issue with my service crashing after garbage
collection has run.

By crashing I mean the app and service completely freeze. I can't error trap
it anywhere - I can only see the error in the mono log.

I have tested my app with ver 403, 404 and 405 beta.

This is a show stopper for my application. And it's pretty inconsistent
sometimes it works other times it crashes.

It doesn't seem to matter if I try and force a GC.Collect at certain places
BEFORE or AFTER any serialization.

I really need some help with this. It seems like there are similar reports
on the web of this error:

1) I know this is a MonoTouch error but it's uncannily similar:
http://stackoverflow.com/questions/5808833/exception-when-webservice-is-called-after-device-got-locked

2) Also has this fix been applied to MfA:
http://stackoverflow.com/questions/5819700/why-is-our-monotouch-app-breaking-in-the-garbage-collector-it-is-not-out-of-mem

3)
http://mono-for-android.1047100.n5.nabble.com/Error-in-downloading-many-files-from-WCF-Web-Service-td4945118.html

The crash occurs when I use serialize like this:

				XmlSerializer formatter = new XmlSerializer(thisType);

				using (StringWriter stringWriter = new
StringWriterWithEncoding(Encoding.UTF8))
				{

					using (XmlWriter xw = XmlWriter.Create(stringWriter))
					{

						formatter.Serialize(xw, source);

					}

					result = stringWriter.ToString();

				}


LOG 1:

02-29 19:25:11.600: I/monodroid-gc(26059): GC cleanup summary: 114 objects
tested - resurrecting 48.
02-29 19:25:14.755: I/monodroid-gc(26059): GC cleanup summary: 84 objects
tested - resurrecting 76.
02-29 19:25:15.430: I/monodroid-gc(26059): GC cleanup summary: 10 objects
tested - resurrecting 10.
02-29 19:25:17.540: I/monodroid-gc(26059): GC cleanup summary: 22 objects
tested - resurrecting 19.
02-29 19:25:24.035: I/mono(26059): Stacktrace:
02-29 19:25:24.035: I/mono(26059):   at
System.Text.StringBuilder.InternalEnsureCapacity (int) <0x000b7>
02-29 19:25:24.035: I/mono(26059):   at System.Text.StringBuilder.Append
(string) <0x000db>
02-29 19:25:24.035: I/mono(26059):   at System.IO.StringWriter.Write
(string) <0x00037>
02-29 19:25:24.035: I/mono(26059):   at
System.Xml.XmlTextWriter.WriteStartElement (string,string,string) <0x00303>
02-29 19:25:24.035: I/mono(26059):   at
System.Xml.DefaultXmlWriter.WriteStartElement (string,string,string)
<0x0003b>
02-29 19:25:24.035: I/mono(26059):   at
System.Xml.XmlWriter.WriteStartElement (string,string) <0x00033>
02-29 19:25:24.035: I/mono(26059):   at
System.Xml.Serialization.XmlSerializationWriter.WriteStartElement
(string,string,object,bool,System.Collections.ICollection) <0x003a3>

LOG 2:

02-29 22:46:02.420: I/monodroid-gc(30626): GC cleanup summary: 403 objects
tested - resurrecting 85.
02-29 22:46:02.900: I/mono(30626): Stacktrace:
02-29 22:46:02.900: I/mono(30626):   at string.ToCharArray (int,int)
<0x00047>
02-29 22:46:02.900: I/mono(30626):   at string.ToCharArray () <0x0001b>
02-29 22:46:02.900: I/mono(30626):   at
System.Xml.XmlTextWriter.WriteEscapedString (string,bool) <0x00077>
02-29 22:46:02.900: I/mono(30626):   at System.Xml.XmlTextWriter.WriteString
(string) <0x0005b>
02-29 22:46:02.900: I/mono(30626):   at
System.Xml.DefaultXmlWriter.WriteString (string) <0x0002b>
02-29 22:46:02.900: I/mono(30626):   at
System.Xml.Serialization.XmlSerializationWriterInterpreter.WritePrimitiveElement
(System.Xml.Serialization.XmlTypeMapping,object,string,string) <0x0005b>



--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Persistent-issues-with-GC-Collect-killing-my-xml-serialization-tp5526144p5526144.html
Sent from the Mono for Android mailing list archive at Nabble.com.


More information about the Monodroid mailing list