# IPersistMemory

The IPersistMemory interface operates exactly as IPersistStreamInit, except that it allows the caller to provide a fixed-size memory block (identified with a void *) as opposed to IPersistStreamInit which involves an arbitrarily expandable IStream.

The cbSize argument to the Load and Save methods indicate the amount of memory accessible through pvMem.

The IsDirty, GetSizeMax, and InitNew methods are semantically and syntactically identical to those in IPersistStreamInit. Only Load and Save differ.

##### When to Implement

An object implements this interface to save itself in memory.

##### When to Use

A container calls the methods of this interface to instruct an object to save and load itself in memory.

Methods in Vtable Order

IUnknown Methods | Description
QueryInterface | Returns pointers to supported interfaces.
AddRef | Increments reference count.
Release | Decrements reference count.

IPersist Method | Description
GetClassID | Returns the class identifier (CLSID) for the component object.

IPersistMemory Methods | Description
IsDirty | Checks the object for changes since it was last saved.
Load | Initializes an object from the memory block where it was previously saved.
Save | Saves an object into the specified memory block and indicates whether the object should reset its dirty flag.
GetSizeMax | Returns the size in bytes of the memory block needed to save the object.
InitNew | Initializes an object to a default state.