title: How would I make garbage collection clean up RCW objects bound to an out-proc COM server?
body: <p>I have a 64-bit .NET process that runs for days. The process consumes a native 32-bit COM server using DCOM. Once in a while the COM server runs out of memory because the .NET process garbage collector only sees the RCWs of the COM objects and those are quite lightweight and "not worth collecting". I need to somehow make garbage collector aware of those COM objects.</p>
  
  <p>For the record, I tried to run the same code periodically force-starting garbage collection and the problem goes away so the problem is not a leak of some kind, just objects not collected fast enough.</p>
  
  <p>Yes, I know there's <code>GC.AddMemoryPressure()</code> which allows to tell the garbage collector that we're now consuming more memory. The problem is the 64-bit .NET process may treat that as "not a big deal" - it's 64-bit and well, gigabyte here and another gigabyte there - "who cares" but the 32-bit process where the objects actually live is much more sensitive to those allocations.</p>
  
  <p>So what may be a "no big deal" for a 64-bit process is surely a big deal for a 32-bit process and I need to somehow make the garbage collector of the 64-bit process be more sensitive to amount of memory used by another process.</p>
  
  <p>How can I handle this situation so that the 64-bit process timely collects the RCWs and the 32-bit COM server doesn't run out of memory?</p>