인프런 커뮤니티 질문&답변
StompAllocator에서 Release 함수 구현시.. Offset을 다시 원래 위치로 복구 해줄 필요가 있나요??
해결된 질문
작성
·
199
0
StompAllocator에서,
void StompAllocator::Dealloc(void* p)
{
// 이건 Offset을 처리해줄 필요없지만... 그래도 모르니...
int64 addressNo = reinterpret_cast<int64>(p);
addressNo &= 0xffffffffffff1000;
::VirtualFree((void*)addressNo, 0, MEM_RELEASE);
}이런식으로 페이지 끝단에 위치했던 p를 다시 페이지 시작 지점으로 offset을 지정 해줄 필요가 있나요??
VirtualFree 는 p가 존재하는 페이지 전부를 해지시켜주는데 해당 페이지 끝단에 있던, 시작주소에 있던.. 그 페이지가 날라가는건 똑같은걸로 아는데요 ㅠㅠ
답변 1
0
Rookiss
지식공유자
If the dwFreeType parameter is MEM_RELEASE, this parameter must be the base address returned by the VirtualAlloc function when the region of pages is reserved.
https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfree
MSDN에서는 이렇게 나오는데요.
만약 말씀하신게 맞다면 그렇게 하셔도 무방합니다.






아 MSDN에서 MEM_RELEASE에서는 VirtualAlloc 시작 주소를 넘겨라고 해놓았군요 ㅎㅎ
답변 감사합니다~ ^^