Question

I have a case where I have to use some classes across AppDomains. To make them work I have them inheriting from MarshalByRefObject. Everything with these classes work as expected. But these classes are used throughout our system, and 99% of the time these classes will be used within only one AppDomain. Are there any negative side effects from inheriting from MarshalByRefObject when using these classes within a single AppDomain?

Thanks,
Skip

Was it helpful?

Solution

Certainly, MRBO has a substantial affect on the code generated by the jitter. Any access to a field of the class results in a call to a helper method implemented in the CLR instead of a single CPU instruction that accesses the field.

This is inevitable, only the CLR knows whether the object is actually a proxy or the real deal. And a proxy needs to emulate a field with a remoting call. If it is not a proxy then you still pay for the helper call overhead, an easy order of magnitude slower.

Whether that truly has an impact on your code is impossible to predict, we're talking about nanoseconds here. You only do something about it if the slowdown becomes noticeable.

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