Hi, Sergey!
You do not need to (and should not attempt to) free the memory you get back from a call to GetIlFunctionBody. This memory can be mapped directly to the module containing the function and is therefore unfreeable.
The general rule of thumb regarding freeing memory is this. If you allocated the memory, you can free it (unless the API docs say not to, such as with IMethodMalloc::Alloc). If the CLR allocates memory and hands it back to you, don't free it (unless the Profiling API docs say you should). In fact, off the top of my head, I can't think of an example where the profiling API hands you memory that you're supposed to free.
|