VirtualAllocEx_ questions
Posted: Mon Feb 20, 2012 1:55 pm
Hi All,
I have a problem with memory and I am trying to track it down, I suspect VirtualAllocEx_ but wanted to get a little feedback from you guys.
I have seen VirtualAllocEx_ used in many places in this forum and others but two things perplex me
1) Why do 99% of the examples not RESERVE the memory but just COMMIT it, from what I have read you should do the following
2) Why, in most examples do people NOT call FlushInstructionCache when allocating memory for code?
[Edit] Found out that this is, it is not needed on x86.
3) Finally for now, I did ask in a older post if "I should free" allocated memory and got the answer that the process will deal with deallocation, I have seen some examples were people call VirtualFreeEx, can anyone confirm if I need to clean up or not?
Thanks
Pete
I have a problem with memory and I am trying to track it down, I suspect VirtualAllocEx_ but wanted to get a little feedback from you guys.
I have seen VirtualAllocEx_ used in many places in this forum and others but two things perplex me
1) Why do 99% of the examples not RESERVE the memory but just COMMIT it, from what I have read you should do the following
Code: Select all
VirtualAllocEx_(hprocess, 0, 2000, #MEM_RESERVE | #MEM_COMMIT , #PAGE_READWRITE)
[Edit] Found out that this is, it is not needed on x86.
3) Finally for now, I did ask in a older post if "I should free" allocated memory and got the answer that the process will deal with deallocation, I have seen some examples were people call VirtualFreeEx, can anyone confirm if I need to clean up or not?
Thanks
Pete