Question

I am experimenting with cross-AppDomain objects, 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?

Was it helpful?

Solution

Remote calls are as easy - but object lifetime and garbage collection are not as simple.

You should read a bit on leases and sponsorships.

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