* Add heap_debug_set_memory_reuse() which allows to disable memory reuse,

keeping all returned heap memory in the 0xdeadbeef state (including the
  first sizeof(void *) bytes otherwise for the free list). While wasting a lot
  of memory it allows you to rely on 0xdeadbeef being always present as no
  future allocation will reuse the freed memory block.
* Also added heap_debug_malloc_with_guard_page() which is intended to allocate
  a memory block so it is aligned that the start of invalid memory past the
  allocation is in an unmapped guard page. However the kernel backend that would
  guarantee this is not yet implemented, so right now this works only by chance
  if no other area happens to be allocated exactly past the created one. With a
  very specifc suspicion you can put that one allocation you get to good use
  though. It causes a crash when accessing memory past the allocation size so
  you actually get a backtrace from where the access happened instead of only
  after freeing/wall checking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35478 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2010-02-15 20:28:15 +00:00
parent ba3d62b66f
commit 081ff2db28
2 changed files with 104 additions and 43 deletions
+12 -7
View File
@@ -5,19 +5,24 @@
#ifndef MALLOC_DEBUG_H
#define MALLOC_DEBUG_H
#include <OS.h>
#ifdef __cplusplus
extern "C" {
#endif
extern status_t heap_debug_start_wall_checking(int msInterval);
extern status_t heap_debug_stop_wall_checking();
status_t heap_debug_start_wall_checking(int msInterval);
status_t heap_debug_stop_wall_checking();
extern void heap_debug_set_paranoid_validation(bool enabled);
extern void heap_debug_validate_heaps();
extern void heap_debug_validate_walls();
void heap_debug_set_memory_reuse(bool enabled);
void heap_debug_set_paranoid_validation(bool enabled);
void heap_debug_validate_heaps();
void heap_debug_validate_walls();
extern void heap_debug_dump_allocations(bool statsOnly, thread_id thread);
extern void heap_debug_dump_heaps(bool dumpAreas, bool dumpBins);
void heap_debug_dump_allocations(bool statsOnly, thread_id thread);
void heap_debug_dump_heaps(bool dumpAreas, bool dumpBins);
void *heap_debug_malloc_with_guard_page(size_t size);
#ifdef __cplusplus
}