[Mono-dev] Need Help on Commons.Xml.Relaxng.dll

Panop Suvaphrom PSuvaphrom at vizrt.com
Mon Oct 25 23:15:05 EDT 2010



-----Original Message-----
From: Atsushi Eno [mailto:atsushieno at veritas-vos-liberabit.com] 
Sent: Tuesday, October 26, 2010 9:34 AM
To: Panop Suvaphrom
Cc: mono-devel-list at lists.ximian.com
Subject: Re: [Mono-dev] Need Help on Commons.Xml.Relaxng.dll

You said you run the examples on the web page you mentioned earlier, right?

Not exactly the same and my code look something like this ...

   public static class XmlRncValidation
    {
        public static void CheckValidAgainstRncResourcePrintingErrors(
            string xmlDoc, string rncName)
        {
            var xmlReader = new XmlTextReader(new StringReader(xmlDoc));
            try
            {
                CheckValidAgainstRncResource(rncName, xmlReader);
            }
            catch (RelaxngException)
            {
                Console.WriteLine("Invalid XML:\n" + xmlDoc);
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Invalid :\n" + ex.Message);
                throw;
            }
            finally
            {
                xmlReader.Close();                
            }
        }

        public static void CheckValidAgainstRncResource(string rncName, XmlReader xmlReader)
        {
            var a = Assembly.GetExecutingAssembly();
            var rncStream = a.GetManifestResourceStream(rncName);
            var sr = new StreamReader(rncStream);
            RelaxngValidatingReader vr = null;
            try
            {
                RelaxngPattern p;
                using (sr)
                {
                    p = RncParser.ParseRnc(sr);
                }

                 vr = new RelaxngValidatingReader(xmlReader, p);

                while (!vr.EOF)
                {
                    vr.Read();
                }

                if (rncStream == null)
                {
                    throw new ArgumentException("Resource not in assembly", rncName);
                }
            }
            finally  
            {
                rncStream.Close();
                sr.Close();
                vr.Close();
             }                        
        }


Which code did you run? How did you confirm profiling numbers? How much was the memory consumption? There should be exact information here and there.

I saw in task manager about 500-600 MB.

Commons.Xml.Relaxng.Derivative objects are created a lot, and lots of them are linked to the same objects so they don't consume more memory. 
You won't be able to see that if you're just looking at VS debugger though.

I see it by using http://memprofiler.com/
However, I don't know much about profiling if you need more info. , please let me know.

Atsushi Eno

On 2010/10/26 10:24, Panop Suvaphrom wrote:
> Hi,
>
>          I have used the Commons.Xml.Relaxng.dll in VS2010.
>          I also think that the memory is going up especially when validation exception occurred.
>          When profiling on .net memory profiler, I can see many of Commons.Xml.Relaxng.Derivative.
>
>         Not sure about this, Do I miss something ?
>
> Thank You,
> Panop S.
>
>
> -----Original Message-----
> From: Atsushi Eno [mailto:atsushieno at veritas-vos-liberabit.com]
> Sent: Saturday, October 23, 2010 1:57 PM
> To: Panop Suvaphrom
> Cc: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] Need Help on Commons.Xml.Relaxng.dll
>
> Hello,
>
> That's an interesting page. I didn't know that and am pretty glad to 
> see it :)
>
> Hmm, but that sounds weird. I tried some of the samples on that page with mono --profile (simpler one), but cannot see such huge memory consumption. Can you show me the --profile result (or any profiling stuff) ?
>
> Commons.Xml.Relaxng is based on James Clark's derivative algorithm[*1] and I have implemented all the optimization trick such as avoiding exponential blowup and memoization. There could be of course bugs that prevents them though.
>
> [*1] http://www.thaiopensource.com/relaxng/derivative.html
>
> Atsushi Eno
>
> On 2010/10/22 15:38, Panop Suvaphrom wrote:
>> Hi,
>>
>>            I am not sure if this is the right place to ask.
>>
>>           Now I have project to develop and validate RNC file that I 
>> have read from 
>> http://www.xs4all.nl/~wrb/Articles/Article_XML_RelaxNG_01.htm
>> <http://www.xs4all.nl/%7Ewrb/Articles/Article_XML_RelaxNG_01.htm>.
>>
>>           My problem is the memory consumption continues increasing 
>> more and more, and then the machine is quite slow.
>>
>>           I try to search on the web but no discussion on this issue.
>> Has anyone known about this and any suggestion would be appreciate.
>>
>>           And also when I turn the validation off from code, memory 
>> consumption is in normal.
>>
>> Big ThanksJ,
>>
>> Panop S.
>>
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
>
>





More information about the Mono-devel-list mailing list