[fpc-pascal] Tips & Tricks: AllocationPreference Registry Key
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Sun Jun 7 13:02:05 CEST 2015
Hi,
I was only recently made aware that this registry key exists. I thought
it might be useful to other developers developing for the Windows
platform. This can help with detecting pointer truncation bugs on the
Windows platform (and then also benefit cross-platform applications)
I hope somebody can find this useful.
Tips & Tricks: AllocationPreference Registry Key
================================================
If you're not a software developer, then you would never have any need
to set this registry key, and you would never be affected by any of the
issues that it causes. If you are a developer, then adding
AllocationPreference with a value of 0x100000 under
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session
Manager\Memory Management\ and rebooting your PC will make Windows
allocate memory from the top down. That is, memory allocations will
start from the highest possible pointer value and then go down on
subsequent allocations, instead of starting from the lowest possible
pointer value and then go up. The key benefit is that it detects pointer
truncation bugs, where a 64-bit application casts pointers to or from
32-bit instead of 64-bit integers. Such bugs can now be found much more
quickly. You'll get pointer values beyond 2^32 right away, instead of
only after your application has allocated more than 4 GB of RAM. It will
likely cause any 64-bit application which has such bugs to crash, so
it's best to do these tests in a virtual machine.
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
More information about the fpc-pascal
mailing list