[Mono-dev] Memory leaks

Miguel de Icaza miguel at ximian.com
Tue Sep 27 18:26:43 EDT 2005


Hello,

> I "ported" a simulation from Visual C# beta 2 to mono this week. You can't 
> really call it porting, because I only had to remove references to Stopwatch. 
> But anyway, thanks to all of you for making it so easy.
> 
> It is a long running application, therefore I used an IA64 at work. Almost 
> everything worked without any hiccups. But after about 12h the memory 
> consumption was up to 4GB. In the beginning it needed only about 50MB. In my 
> opinion, the memory consumption shouldn't raise over the time because my main 
> loop looks as follows:
> 
> foreach(set_of_parameters){
>  Job job = new Job(parameters);
>  job.run();	
> }
> 
> and there shouldn't survive any references in global/static variables. Is 
> there any tool like the .net memory profiler 
> (http://www.scitech.se/memprofiler/) for Linux? It would be nice to see how 
> many instances of each class exist at a given time or navigating the graph 
> created by the dependencies between the instances.

You can also use an alternative memory profiler, I just added this to
the mono documentation:


There are a number of external profilers that have been developed for
Mono, we will update this section to contain the profilers.

The Live Type profiler shows at every GC iteration all of the live
objects of a given type.   To install you must download the profiler
from Mono's SVN:

        svn co svn://svn.myrealbox.com/source/trunk/heap-prof
        cd heap-prof
        ./autogen
        make
        make install

To use the profiler, execute:

        mono --profile=desc-heap program.exe

The output of this profiler looks like this:

        Checkpoint at 102 for heap-resize
           System.MonoType : 708
           System.Threading.Thread : 352
           System.String : 3230
           System.String[] : 104
           Gnome.ModuleInfo : 112
           System.Object[] : 160
           System.Collections.Hashtable : 96
           System.Int32[] : 212
           System.Collections.Hashtable+Slot[] : 296
           System.Globalization.CultureInfo : 108
           System.Globalization.NumberFormatInfo : 144

The first line describes the iteration number for the GC, in this case
checkpoint 102.

Then on each line the type is displayed as well as the number of bytes
that are being consumed by live instances of this object.




More information about the Mono-devel-list mailing list