MemoryTracking.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // Allows an external memory tracking utility (such as MemSpect) to track recycler allocations
  6. // Routines called to allow tracking memory. These routines are empty for RET
  7. // builds but allow external tools (such as Memspect) to track arena allocations individually
  8. // for CHK and TEST builds. Requires the appropriate configuration flag, e.g. -MemspectEnabled.
  9. namespace Memory
  10. {
  11. class ArenaAllocator;
  12. class ArenaMemoryTracking
  13. {
  14. public:
  15. static void Activate();
  16. static void ArenaCreated(Allocator *arena, __in LPCWSTR name);
  17. static void ArenaDestroyed(Allocator *arena);
  18. static void ReportAllocation(Allocator *arena, void *address, size_t size);
  19. static void ReportReallocation(Allocator *arena, void *address, size_t existingSize, size_t newSize);
  20. static void ReportFree(Allocator *arena, void *address, size_t size);
  21. static void ReportFreeAll(Allocator *arena);
  22. };
  23. class Recycler;
  24. class RecyclerMemoryTracking
  25. {
  26. public:
  27. static bool IsActive();
  28. static void Activate();
  29. static void ReportRecyclerCreate(Recycler * recycler);
  30. static void ReportRecyclerDestroy(Recycler * recycler);
  31. static void ReportAllocation(Recycler * recycler, __in void *address, size_t size);
  32. static void ReportFree(Recycler * recycler, __in void *address, size_t size);
  33. static void ReportUnallocated(Recycler * recycler, __in void* address, __in void *endAddress, size_t sizeCat);
  34. };
  35. class PageTracking
  36. {
  37. public:
  38. static void Activate();
  39. static void PageAllocatorCreated(PageAllocator *pageAllocator);
  40. static void PageAllocatorDestroyed(PageAllocator *pageAllocator);
  41. static void ReportAllocation(PageAllocator *pageAllocator, __in void *address, size_t size);
  42. static void ReportFree(PageAllocator *pageAllocator, __in void *address, size_t size);
  43. };
  44. }