Memory leak in simple cross app object
I am experimenting with cross-AppDomain objects, 开发者_StackOverflow社区and found one quite strange thing.
When I call a remote method, which is allocating a MemoryStream object and returning it's reference (and which is immediately disposed by the caller), memory usage is quite significantly increasing and is not dropping down, even after calling GC.Collect().
On the calling method which returns new String or byte[] object every time, there is no leak.
The Memory profiler shows that most live objects are of type Char[] and String (in case of MemoryStream).
The question is - did I misunderstand something, and remote calls are not so simple as inheriting from MarshalByRefObject?
Remote calls are as easy - but object lifetime and garbage collection are not as simple.
You should read a bit on leases and sponsorships.
精彩评论