开发者

How long do objects stay in memory after a soap request to WCF?

I was wondering how long do objects instantiated during a soap request ( which do not implement IDisposable ) stay in memory?

f开发者_运维技巧or example:

...
public GetRecordsResponse GetRecords(GetRecordsRequest request)
    {
        GetRecordsTransaction transaction = new GetRecordsTransaction();
        GetRecordsResponse response = transaction.GetResponse(request);
        return response;
    }
...

How long would the transaction stay in memory?

As soon as soap sends the response? session (if that exists in wcf)?


Implementing IDisposable has little to do with managed memory. Garbage collection is about cleaning up managed memory; but IDisposable is intended to allow control of releasing unmanaged resources.

From your code sample, you have no guarantee of how long your objects are in memory for, and you should definitely not make any assumptions about how soon (or late) the garbage collector will reclaim the memory for those objects once they are no longer referenced by your code.

May I ask why you need to know? It sounds as though you are expecting your transactions to have some sort of behaviour at the point of garbage collection, when what you really want is to explicitly rollback or commit them. If you could explain your root problem, that might help clarify the question.


They are not cached. They may happen not to be garbage collected for a while.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜