Skip to content

Latest commit

 

History

History
128 lines (90 loc) · 4.41 KB

nf-winbase-globalfree.md

File metadata and controls

128 lines (90 loc) · 4.41 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.GlobalFree
GlobalFree function (winbase.h)
Frees the specified global memory object and invalidates its handle.
GlobalFree
GlobalFree function
_win32_globalfree
base.globalfree
winbase/GlobalFree
base\globalfree.htm
base
5fe910ac-f857-45ca-9c0f-4f9ba3c5e61b
12/05/2018
GlobalFree, GlobalFree function, _win32_globalfree, base.globalfree, winbase/GlobalFree
winbase.h
Windows.h
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
Kernel32.lib
Kernel32.dll
Windows
19H1
GlobalFree
winbase/GlobalFree
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
GlobalFree

GlobalFree function

-description

Frees the specified global memory object and invalidates its handle.

Note  The global 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 global function should be used. For more information, see Global and Local Functions.
 

-parameters

-param hMem [in]

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

-returns

If the function succeeds, the return value is NULL.

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

-remarks

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

The GlobalFree function will free a locked memory object. A locked memory object has a lock count greater than zero. The GlobalLock function locks a global memory object and increments the lock count by one. The GlobalUnlock function unlocks it and decrements the lock count by one. To get the lock count of a global memory object, use the GlobalFlags function.

If an application is running under a debug version of the system, GlobalFree will issue a message that tells you that a locked object is being freed. If you are debugging the application, GlobalFree 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 GlobalAlloc.

-see-also

Global and Local Functions

GlobalAlloc

GlobalFlags

GlobalLock

GlobalReAlloc

GlobalUnlock

Memory Management Functions