### Memory Management

IDL encoding services stubs handle memory management in the same way as RPC client stubs: when you call an operation to which the encode and/or decode attributes have been applied, the encoding services stub uses whatever client stub memory management scheme is currently in effect. See Memory Management at the beginning of this topic for further details on client stub memory management defaults and setting up memory management schemes.

You can control which memory management scheme the stubs will use by calling the rpc_ss_swap_client_alloc_free( ) and rpc_ss_set_client_alloc_free( ) routines. The first routine sets the memory management routines used by both the encoding and decoding stubs, and the second routine restores the previous memory management scheme after encoding and decoding are complete.

Note that the memory management scheme established, whether explicitly or by default, is on a per-thread basis.

###