yanzhengli/coreVM — pull request #17 by yanzhengli (2014-12-02 07:01:14+00:00)
Title: [COREVM-78] Fix memory allocator usage tracking

Currently `heap_mem_allocator` has a member (`m_allocated_size`) that is used for tracking the amount of memory used. This number is updated after each call of `malloc()` or `free()` of the encapsulated allocation scheme. However, the buddy allocation scheme incorrectly updates this value because it reports the amount of memory freed using the value of the entire block, rather than the value of the actual memory freed. This causes the `assert`s in the `allocate()` and `deallocate` of `heap_mem_allocator` disabled for now, but this should be fixed.

The solution is to add a field in the block descriptor called `actual_size` that tracks the actual size allocated in a block. This also deprecates the use of the `.free` field since an actual size of 0 means the block is free, and a value higher than 0 means otherwise.

Also updated the allocator debug print.

![corevm-79_allocator_debug_print](https://cloud.githubusercontent.com/assets/554685/5258949/db48d65c-79ad-11e4-9ea5-a5d0fa479f79.png)
Sample updated allocator debug print