Skip to content

Latest commit

 

History

History
134 lines (92 loc) · 4.56 KB

nf-winbase-localfree.md

File metadata and controls

134 lines (92 loc) · 4.56 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winbase.LocalFree
LocalFree function (winbase.h)
Frees the specified local memory object and invalidates its handle.
LocalFree
LocalFree function
_win32_localfree
base.localfree
winbase/LocalFree
base\localfree.htm
base
a0393983-cb43-4dfa-91a6-d82a5fb8de12
12/05/2018
LocalFree, LocalFree function, _win32_localfree, base.localfree, winbase/LocalFree
winbase.h
Windows.h
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
Kernel32.lib
Kernel32.dll
Windows
19H1
LocalFree
winbase/LocalFree
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-Heap-Obsolete-l1-1-0.dll
kernel32legacy.dll
API-MS-Win-DownLevel-Kernel32-l2-1-0.dll
API-MS-Win-Core-misc-l1-1-0.dll
KernelBase.dll
MinKernelBase.dll
API-MS-Win-Core-Heap-l2-1-0.dll
LocalFree

LocalFree function

-description

Frees the specified local memory object and invalidates its handle.

Note  The local functions have greater overhead and provide fewer features than other memory management functions. New applications should use the heap functions unless documentation states that a local function should be used. For more information, see Global and Local Functions.
 

-parameters

-param hMem [in]

A handle to the local memory object. This handle is returned by either the LocalAlloc or LocalReAlloc function. It is not safe to free memory allocated with GlobalAlloc.

-returns

If the function succeeds, the return value is NULL.

If the function fails, the return value is equal to a handle to the local memory object. To get extended error information, call GetLastError.

-remarks

If the process tries to examine or modify the memory after it has been freed, heap corruption may occur or an access violation exception (EXCEPTION_ACCESS_VIOLATION) may be generated.

If the hMem parameter is NULL, LocalFree ignores the parameter and returns NULL.

The LocalFree function will free a locked memory object. A locked memory object has a lock count greater than zero. The LocalLock function locks a local memory object and increments the lock count by one. The LocalUnlock function unlocks it and decrements the lock count by one. To get the lock count of a local memory object, use the LocalFlags function.

If an application is running under a debug version of the system, LocalFree will issue a message that tells you that a locked object is being freed. If you are debugging the application, LocalFree will enter a breakpoint just before freeing a locked object. This allows you to verify the intended behavior, then continue execution.

Examples

For an example, see LocalAlloc.

-see-also

Global and Local Functions

GlobalFree

LocalAlloc

LocalFlags

LocalLock

LocalReAlloc

LocalUnlock

Memory Management Functions