When doing NtAllocateVirtualMemory, you need to MEM_RELEASE if you intend to

free the memory, otherwise you'll get stray address space hanging around.  This
was noticeable as a leak if you just left the command prompt sitting, because
every DC allocated to blink the cursor kept address space that was never freed.

svn path=/trunk/; revision=30567
This commit is contained in:
Art Yerkes 2007-11-18 23:59:48 +00:00
parent 4ba2b63f3b
commit 74c80e3705
3 changed files with 3 additions and 3 deletions

View file

@ -102,7 +102,7 @@ EngFreeUserMem(PVOID pv)
PUSERMEMHEADER Header = ((PUSERMEMHEADER) pv) - 1;
ULONG MemSize = sizeof(USERMEMHEADER) + Header->MemSize;
ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &Header, &MemSize, MEM_DECOMMIT);
ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &Header, &MemSize, MEM_RELEASE);
}
/*

View file

@ -887,7 +887,7 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
if (! NT_SUCCESS(Status))
{
ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem,
&Info.LParamSize, MEM_DECOMMIT);
&Info.LParamSize, MEM_RELEASE);
SetLastNtError(Status);
RETURN( (BOOL) -1);
}

View file

@ -2418,7 +2418,7 @@ DC_FreeDcAttr(HDC DCToFree )
NTSTATUS Status = ZwFreeVirtualMemory(Pid,
&Entry->UserData,
&MemSize,
MEM_DECOMMIT);
MEM_RELEASE);
if (NT_SUCCESS(Status))
{
DPRINT("DC_FreeDC DC_ATTR 0x%x\n", Entry->UserData);