PerCall/Multiple & static variable RRS feed

  • Question

  • Hi,

    All my services are configured as follows :

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple, ReleaseServiceInstanceOnTransactionComplete = false, TransactionIsolationLevel = IsolationLevel.Serializable)]

    [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]

    Under heavy load the memory concumption increases and is never released.

    After investigating with PerfView it appears that the static variables are leaking.

    Are static variables not automatically disposed after each call since it is PerCall.

    The gcServer is set to true.

    Maybe the garbage collector has not time enough to do his job (because of the load) ?

    Please help.


    Friday, February 8, 2013 7:43 AM


  • Hi,

    Static variables are global variables. From my experience, whatever kind of InstanceContextMode you use, exactly one copy of the variable is stored in memory, and it will not be released until the application exits. So it is not recommended to store large amount of data in static variables, but static variables do not increase memory usage as request number increases, as only one copy exists in memory.

    Best Regards,

    Ming Xu

    Ming Xu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 11, 2013 9:12 AM