XMemSetOption
Sets a configuration setting for XMem.Syntax
Parameters
option _In_Type: XMEM_OPTION The option configuration to set.
Return value
Type: voidRemarks
XMemSetOption is used to configure optional behaviors of the XMem system. eXMEMOPT_VALIDATE_XMEMALLOC (BOOL)Enables verification of the memory properties returned from a call to XMemAlloc to ensure that it meets the alignment, page size, page protections, and cache attributes of the requested memory type. This is intended to be used at development time to catch errors in private implementations of XMemAlloc. Source code for the verification logic is provided as part of the Microsoft Game Development Kit (GDK). For more information, see the
XmpVerifyXMemAllocRoutine function in \GXDK\gameKit\Source\amd64\heap.c.
eXMEMOPT_RAISE_HEAPFREE_CALLBACK_ON_REALLOC (BOOL)
Enables calling the HeapFree callback configured by
XMemSetWin32HeapTrackingHooks when HeapReAlloc has been called. Without this option the HeapReAlloc callback is called after the realloc has occurred with the old and new address. When this option is set the HeapFree callback will additionally be called prior to the HeapReAlloc call with the old address.
eXMEMOPT_XMEMALLOCDEFAULT_TAG_VIRTUALALLOC (BOOL)
Enables the addition of a commit tag on every call to
XMemVirtualAlloc that is made by XMemAllocDefault to satisfy an allocation (for example, when the allocation request is too large to fit within an internal XMem heap). The commit tag is added with XMemMakeTag(‘XmVA’). This enables a developer to compute the total amount of memory consumed by XMemAllocDefault. For more information see Diagnostics and memory tracking.
eXMEMOPT_SET_XMEM_TAG_TREE_SIZE (INT)
When set, the allocated storage space for custom XMem Tags will be set to the specified size in megabytes.
eXMEMOPT_XMEM_WARN_WHEN_TAG_TREE_FULL (BOOL)
When set, if the allocated storage for custom XMem Tags is exhausted, a runtime warning will be raised through
XError.
eXMEMOPT_XMEMALLOCDEFAULT_DISABLEPAGESIZEDEMOTION (BOOL)
The internal XMem heaps used by
XMemAllocDefault are initially created using 2MB pages but are configured to fallback to demote to 64KB pages if they encounter a failure to grow the heap using 2MB pages. This flag disables the demotion behavior. Source code for the page size demotion logic is provided as part of the Microsoft Game Development Kit (GDK). For more information, see the XmpAllocateHeapMemory function in \GXDK\gameKit\Source\amd64\heap.c
eXMEMOPT_XMEMALLOCDEFAULT_TRAPUSEAFTERFREE (BOOL)
This option configures
XMemAllocDefault to promote any allocations that would normally be serviced by the internal XMem heaps to XMemVirtualAlloc calls. Furthermore the memory is freed using VirtualFree(MEM_DECOMMIT). While this intentionally leaks virtual address space and will eventually lead to an allocation failure, it is a useful diagnostics aid for catching use-after-free errors. Source code for promotion logic is provided as part of the Microsoft Game Development Kit (GDK). For more information, see the usage of the XmpTrapUseAfterFree variable in \GXDK\gameKit\Source\amd64\heap.c
eXMEMOPT_XMEMALLOCDEFAULT_USE64KPAGES (BOOL)
This option configures
XMemAllocDefault to use 64KB pages instead of 2MB pages for the internal XMem heaps. Additionally, heaps using 64KB pages have a commit/decommit granularity of 512KB instead of 2MB. Source code for implementation of XMemAllocDefalt is provided as part of the Microsoft Game Development Kit (GDK). For more information, see the file \GXDK\gameKit\Source\amd64\heap.c
eXMEMOPT_ALLOW_WRITEABLE_FILEMAPPINGS (BOOL)
When enabled, this option allows calls to
CreateFileMappingA/W to succeed when called with writable flags.
Requirements
Header: xmem.h Library: xmem.libSupported Platforms: XBOX One family consoles and XBOX Series consoles
