I have a problem with RCWs not being timely collected. I think of periodically force-starting garbage collection from inside code. However I'm not sure if that will have some undesired slowdown.
I'm not actually interested in collecting all objects, I only need RCWs collected and they all have System.__ComObject
type. I guess that collecting only them would be faster.
Is it possible to force garbage collection for objects of certain type only?
No, It's not possible, you can only force a garbage collector to run but you can not force it to work according to your logic.
For more information on garbage collector please read this: https://msdn.microsoft.com/en-us/library/ee787088(v=vs.110).aspx
Also GC is a static class, we can't override any of it's method :(