开发者

Does Marshal.ReleaseComObject call the garbage collector?

开发者 https://www.devze.com 2022-12-25 02:21 出处:网络
I was asked this question today by a colleague, and couldn\'t find any clue on the Internet... Can someone tell me if calling Marshall.ReleaseComObject()directly calls the garbage collector ?

I was asked this question today by a colleague, and couldn't find any clue on the Internet... Can someone tell me if calling Marshall.ReleaseComObject()directly calls the garbage collector ? As I understand it, it only removes COM references, and then 开发者_StackOverflow中文版the G.C. cleans memory on its next pass, but I can be mistaken...

Thanks in advance for your help!


Looking at the implementation of ReleaseComObject in Reflector shows that it doesn't. It eventually calls a native method, but I would be surprised if that could somehow force a garbage collect.

The documentation of RCW says that

The runtime performs garbage collection on the RCW.

I would interpret that as the RCW is handled by regular GC.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号