Question

I played with .NET profiling API (ICorProfilerCallback) and quickly discovered that FunctionID is not stable (it may be reused, see http://msdn.microsoft.com/en-us/library/bb384619.aspx). That's all fine. I came up with the idea to encode a method with the module version ID (MVID) and the method token (mdTokenDef).

However, I am concerned that this is space ineffective (16 bytes for the GUID + 4 bytes for the token). Right now I consider to use some sort of hash (32bit hash should be enough I think).

What do you think, are there better ways to encode a method?

Was it helpful?

Solution

Hard to get this wrong, FunctionIDs are stable until the appdomain is torn down. The FunctionUnloadStarted callback is the most direct way to purge the id from your symbol table.

Do beware of generics. The methods of, say, List<Foo> and List<Bar> share the same function id when Foo and Bar are reference types. That's code re-use at work, a feature of .NET generics.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top