Platform SDK: Memory

ResetWriteWatch

The ResetWriteWatch function resets the write-tracking state for a region of virtual memory. Subsequent calls to the GetWriteWatch function will only report pages that have been written to since the reset operation.

UINT ResetWriteWatch(
  LPVOID lpBaseAddress,     // base address
  SIZE_T dwRegionSize       // size of memory region
); 

Parameters

lpBaseAddress
[in] Pointer to the base address of the memory region for which to reset the write-tracking state. This address must be in a memory region that was allocated by the VirtualAlloc function with MEM_WRITE_WATCH.
dwRegionSize
[in] Specifies the size, in bytes, of the memory region for which to reset the write-tracking information.

Return Values

If the function succeeds, the return value is zero.

If the function fails, the return value is a nonzero value.

Remarks

The ResetWriteWatch function can be useful to an application such as a garbage collector. The application calls the GetWriteWatch function to retrieve the list of written pages and then writes to those pages as part of its cleanup operation. Then the garbage collector calls ResetWriteWatch to remove the write-tracking records caused by its cleanup.

You can also reset the write-tracking state of a memory region by specifying WRITE_WATCH_FLAG_RESET when you call GetWriteWatch.

If you use ResetWriteWatch, you must ensure that no threads write to the region during the interval between the GetWriteWatch and ResetWriteWatch calls. Otherwise, there may be written pages that you fail to detect.

Requirements

  Windows NT/2000: Unsupported.
  Windows 95/98: Requires Windows 98.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.

See Also

Memory Management Overview, Memory Management Functions, GetWriteWatch, VirtualAlloc