A New Garbage Collector and Memory Profiler for iOS/MonoTouch
MonoTouch for iOS now supports the generational garbage collector SGen. Until recently this was an experimental option only available on the full version of Mono. Along with it comes a Memory Profiler for iOS that it accessible via the MonoDevelop IDE.
The generational garbage collector SGen replaces Mono’s traditional Boehm garbage collector. While it is expected to have better performance, SGen is still hampered by its conservative scanning. In the future SGen is expected to switch to a precise stack marking system which should significantly reduce nursery fragmentation.
The iOS profiler supports two modes, the default being Heap Analysis. In this mode memory snapshots can be taken on demand or by a trigger. The trigger can be set to a certain number of garbage collection cycles or a time-based interval. Standard tools such as comparing snapshots and determining how an object is rooted in memory are included.
Performance Analysis supports statistical sampling and the more accurate but slower enter/leave event logging. Statistical sampling takes snapshots of the application and estimates how fast each method is based on how often it happens to be caught by the sampler. Enter/leave event logging literally records a log entry each time a function is begun or completed. This offers a complete record of where time is being spent, but at a serious performance cost. This mode can also capture the stack traces associated with object allocation.
MonoDevelop 2.8.5 and MonoTouch 5.1.1 are required to use this tool. For the particular project, the debugging, profiling, and the SGen garbage collector options must be enabled.
Ruslan Meshenberg Sep 21, 2014