Hoarding is not an often-used feature. It is most often used to prevent problems related to memory being deallocated by one part of the program and another part using this memory, not knowing it is deallocated. For two examples of how hoarding is used, see
“Hoarding”.
Tells you how to start MemoryScape. It also contains an overview of the kinds of information you can obtain.
Tell MemoryScape to hoard memory by selecting the Memory Debugging Options screen. (This is described in
Task 3: “Setting MemoryScape Options”.) Next, select
Extreme. If you need to tune how MemoryScape hoards memory, select
Advanced Options.
Figure 73 shows the portion of the options page where you set hoarding options.
Hoarding is actually a very simple process. When your program deallocates memory, MemoryScape stashes the deallocation request away. It also records some information about the size of the block that would have been deallocated. And then it ignores the deallocation request.
Ignoring the deallocation request means that the memory stays “good” and other parts of the program can continue to access this good information instead of using data that may have incorrect values. Said differently, the program can keep executing with the correct information a while longer. This improves your chances of finding where the problem is.
MemoryScape doesn’t just keep ignoring your program’s deallocations request. By default, MemoryScape hoards 32 requests. Also by default, it only defers the deallocation of up to 256 KB of memory. You can, of course, change either of these values by using MemoryScape options.
To hoard all deallocated memory, set the maximum KB and blocks to unlimited by entering
0 in the hoarding control fields. To prevent or delay your program from running out of memory when you use this setting, use the advanced option to set MemoryScape to automatically release hoarded memory when available memory gets low.
You can also set a threshold for the hoard size so MemoryScape can warn you when available memory is getting low. If the hoard size drops below the threshold, MemoryScape halts execution and notifies you. You can then view a Heap Status or Leak report to see where your memory is being allocated.