IoFreeMdl

Frees a Memory Descriptor List (MDL).

VOID IoFreeMdl(PMDL Mdl);

Parameters

Mdl [in] Pointer to the MDL to be freed. This pointer must have been returned by a previous call to IoAllocateMdl or IoBuildMdlForNonCachedCopy.

Description

The IoFreeMdl routine frees a Memory Descriptor List (MDL) that was previously allocated by IoAllocateMdl or built by IoBuildMdlForNonCachedCopy.

It is essential to call IoFreeMdl when an MDL is no longer needed to prevent memory leaks. The system can reuse the memory associated with the freed MDL.

This routine can be called at any IRQL.

Remarks

When you are finished with an MDL, you must free it using IoFreeMdl. Failure to do so will result in a memory leak.

An MDL can also be freed by passing its pointer to IoFreeIrpSpWithMdl if the MDL is associated with an IRP stack location.

The MdlFlags field of the MDL is examined by IoFreeMdl. If the MDL was allocated with the MDL_ALLOCATED_INVALID_ADDRESS flag, the system also frees the associated virtual address range.

See Also

Note

This routine is part of the Windows Driver Kit (WDK) and is used by kernel-mode drivers.