1

Resolved

Perfomance on load log file.

description

On load big file i get exception: "systemoutofmemory" on line:
string sBuffer = string.Format("<root>{0}</root>", streamReader.ReadToEnd());
You can rewrite part of method "ParseLogFile" for increase perfomance and decrease usage of memory:
const string log4J = "http://jakarta.apache.org/log4j";
var settings = new XmlReaderSettings
         {
         ConformanceLevel = ConformanceLevel.Fragment
            };
var nt = new NameTable();
var mgr = new XmlNamespaceManager(nt);
mgr.AddNamespace("log4j", log4J);
var pc = new XmlParserContext(nt, mgr, string.Empty, XmlSpace.Default);
using (var streamReader = new StreamReader(path, System.Text.Encoding.Default, true))
using (var xmlTextReader = XmlReader.Create(streamReader, settings, pc))
{
                var itemId = 1;
                while (xmlTextReader.Read())
etc....

comments