Mono profiler hooking on Unity

On the project i'm currently working on, we noticed lots of GC.Collect triggers. Since our object count is quite "small" (comparing to what it will going to be in real cases) we wanted to track down objects creations and collections (and since the codebase is quite big now, i think it would be quite difficult to just deactivate some parts to identify the guilty code)

Since Unity launches its own Mono process, i've wanted to know if it was possible to pass launch parameters to Unity's Mono, to enable Mono profilers (i'm thinking about HeapBuddy and HeapShot).

And BTW, if anyone knows if those kind of profiling tools will be enabled in the upcoming Unity 3.0 version, feel free to mention it.


Florian Derudder

The talk you mentioned has moved, it can be found in Unite 09 - Optimizing for Unity iPhone 1.5

That said, the talk about GC is for all practical purposes useless. It says to enable the internal profiler, and that it displays the allocated heap size and the used heap size. Well, ok, but that does not help me at all figure out where I am allocating these objects and what they are.

Imagine a cpu profiler that told you the total amount of time it takes for a program to run, but it does not break it down by method.

There's some real good information on optimizing for the GC here:

You cannot pass your own arguments to mono. (we also dont spawn a mono process by the way, it runs in the same process in which unity runs)