64BitAllocDebugger.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright The kNet Project.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License. */
  11. #pragma once
  12. /** @file 64BitAllocDebugger.h
  13. @brief Virtually reserves all memory on Windows in the < 4GB memory area so that all
  14. pointers used by the application are outside the 32-bit range.
  15. Idea and code taken from http://randomascii.wordpress.com/2012/02/14/64-bit-made-easy/ */
  16. #ifdef _WIN64
  17. #include <vector>
  18. class BottomMemoryAllocator
  19. {
  20. public:
  21. BottomMemoryAllocator();
  22. ~BottomMemoryAllocator();
  23. std::vector<void *> virtualAllocated;
  24. std::vector<void *> heapAllocated;
  25. std::vector<void *> mallocAllocated;
  26. void ReserveBottomMemory();
  27. void FreeBottomMemory();
  28. };
  29. #else
  30. /// On other platforms than 64-bit Windows, this debugging feature is not enabled.
  31. class BottomMemoryAllocator {};
  32. #endif