[Mono-list] newbie - understanding profiler data

Alan alan.mcgovern at gmail.com
Wed Aug 31 19:49:01 EDT 2011


To be honest, the numbers mean nothing by themselves. Why are you surprised
about the memory usage? Apparently there's 110mb of data being allocated by
the streamwriter. This is because you're creating thousands of
streamwriters.

If you find the amount of memory being allocated (and released) by
streamwriters to be excessive, you should rewrite your code so that you
reuse them were appropriate instead of creating new ones.

Similar optimisations could potentially be applied to your usage of the
Dictionary class. You're allocating a lot of them. Would it be possible for
you to call Clear on a dictionary and then reuse it?

Alan

On 31 Aug 2011 16:51, "pjsmith" <pjsmith at mtgsy.net> wrote:
> Hi,
>
> My vb.net app running under mono on linux(built under .net on windows) is
> using a lot of memory. I tried to use the profiler running on linux to see
> where this is all going, but having some problems interpreting exactly
what
> I see. I read the profiler info on the mono site, but whilst it explains
> how to use it, it doesn't do much about telling how to interpret the
> results!
>
> I'm seeing data like the following and am surprised at the memory usage.
>
> ########################
> 118830 KB System.IO.StreamWriter::Initialize(Encoding,int)
> 79194 KB 4948 System.Byte[]
> 39635 KB 4948 System.Char[]
> Callers (with count) that contribute at least for 1%:
> 4944 99 % System.IO.StreamWriter::.ctor(string,bool,Encoding,int)
> ########################
> 102769 KB
>
Mono.Globalization.Unicode.SortKeyBuffer::Initialize(CompareOptions,int,string,bool)
> 102769 KB 3599832 System.Byte[]
> Callers (with count) that contribute at least for 1%:
> 449979 100 %
>
Mono.Globalization.Unicode.SimpleCollator::GetSortKey(string,int,int,CompareOptions)
> ########################
> 81311 KB System.Collections.Generic.Dictionary`2::Resize()
> 31979 KB 54578 .Link[]
> 16458 KB 54598 System.String[]
> 16457 KB 54595 System.Int32[]
> 16416 KB 54578 System.Object[]
> Callers (with count) that contribute at least for 1%:
> 54581 99 %
> System.Collections.Generic.Dictionary`2::set_Item(TKey,TValue)
> ########################
> 60706 KB System.String::ToCharArray()
> 60706 KB 305281 System.Char[]
> Callers (with count) that contribute at least for 1%:
> 283019 92 %
> Microsoft.VisualBasic.Strings::Replace(string,string,string,int,int,bool)
> 17182 5 %
> Microsoft.VisualBasic.Strings::Split(string,string,int,CompareMethod)
> 4969 1 % System.IO.TextWriter::.ctor()
> ########################
> 60047 KB System.Text.StringBuilder::.ctor(string,int,int,int,int)
> 60047 KB 294018 System.String
> Callers (with count) that contribute at least for 1%:
> 294018 100 % System.Text.StringBuilder::.ctor(string,int,int,int)
> ########################
> 56349 KB System.String::Remove(int,int)
> 56349 KB 217892 System.String
> Callers (with count) that contribute at least for 1%:
> 217892 100 % ConsoleApplication1.Module1::GetRecords(string,soa)
> ########################
> 39647 KB System.IO.FileStream::InitBuffer(int,bool)
> 39647 KB 4953 System.Byte[]
> Callers (with count) that contribute at least for 1%:
> 4948 99 %
>
System.IO.FileStream::.ctor(string,FileMode,FileAccess,FileShare,int,bool,FileOptions)
> ########################
> 38670 KB
>
Mono.Globalization.Unicode.SimpleCollator::GetSortKey(string,int,int,CompareOptions)
> 38670 KB 449979 Mono.Globalization.Unicode.SortKeyBuffer
> Callers (with count) that contribute at least for 1%:
> 449979 100 %
>
Mono.Globalization.Unicode.SimpleCollator::GetSortKey(string,CompareOptions)
> ########################
> 32156 KB System.String::ConcatInternal(string[],int)
> 32156 KB 86981 System.String
> Callers (with count) that contribute at least for 1%:
> 86981 100 % System.String::Concat(string[])
> ########################
> 29879 KB System.String::SubstringUnchecked(int,int)
> 29879 KB 1394496 System.String
> Callers (with count) that contribute at least for 1%:
> 1715586 77 % System.String::Substring(int,int)
> 449964 20 % System.String::Substring(int)
> 37896 1 % System.Text.StringBuilder::ToString()
> ########################
> 27962 KB System.String::CreateString(char,int)
> 27962 KB 1211286 System.String
> Callers (with count) that contribute at least for 1%:
> 1211286 100 % System.String::.ctor(char,int)
> ########################
> 27741 KB maxmind.LookupService::init()
> 27741 KB 3 System.Byte[]
> Callers (with count) that contribute at least for 1%:
> 1 100 % maxmind.LookupService::.ctor(string,int)
> ########################
> 25583 KB System.Text.Encoding::GetBytes(string)
> 25583 KB 1433648 System.Byte[]
> Callers (with count) that contribute at least for 1%:
> 1421228 99 %
> MySql.Data.MySqlClient.MySqlPacket::WriteStringNoNull(string)
>
> I've tried calling gc.collect (I know, bad), but it doesn't help much. Now
> experimenting with .dispose, but this is all managed code, so not sure any
> of this should really be needed?
>
> Mono version is 2.4.4 and I'm running it under Ubuntu 10.4.
>
> Does anyone have any suggestions or pointers to material where I can learn
a
> bit more about this, or any suggestions for preserving memory when running
> apps under mono?
>
> Thanks.
>
> --
> View this message in context:
http://mono.1490590.n4.nabble.com/newbie-understanding-profiler-data-tp3781405p3781405.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110901/c6c30153/attachment-0001.html 


More information about the Mono-list mailing list