Question

"It is important to note that a heap block might be considered busy in the eyes of the back end allocator but still not being used by the application. The reason behind this is that any heap blocks that go on the front end allocator’s look aside list still have their status set as busy." -- Advanced Windows Debugging p.267

My question reguarding this is : if the heap block status is set as busy , why would the front end allocator add it to the LAL as available for use ?

In other words, the status flag is either indicating either the block is busy or free. So why the free blocks aren't in the LAL , and how can those blocks be assigned to the LAL if their status flag is set to busy (they can be busy or not as the statement say) ?

Was it helpful?

Solution

The front end allocator would add it to the LAL as available for use because it is available for use. The block was freed to the front end allocator, that's how it got the block in the first place. The next caller to the front allocator who requests a block of the appropriate size could be given that block because from the front end allocator's point of view, it's free. None of its clients is using it.

The point of the LAL is to minimize the work the front end allocator makes the back end allocator do. So what the front end allocator does is keep blocks that were freed to the front end allocator in the LAL instead of returning them to the back end allocator. The back end allocator shows them as busy because they are busy -- the front end allocator is using them. But they are also free, the front end allocator can assign them without having to change their status in the back end allocator.

If the front end allocator changed the busy status of blocks in the LAL, that would totally defeat the point of the LAL. Each addition or removal of a block on the LAL would require talking to the back end allocator (to change the busy status) and the whole point of the LAL was to prevent the front end allocator from having to do that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top