When picking out a good set of code examples to model a custom memory manager after, one must consider what one is looking for in objectives.
For example, what use would it be to have a custom memory manager that still uses the new/delete with the OS malloc if the custom memory manager was to be built around that purpose? I almost fell into that one, but that example I came across still called new and delete on char* groups to model bytes.
Instead, I found a much better example that suggests using a customized malloc (just grabbing the data instead of using OS malloc) then applying a placement new using a templated new/delete (array included). So far I'm liking this method!
I'm also learning about byte alignment; apparently if one masks off the log2(n) least significant bits from an address, one can get the n-byte aligned address from that address. Neat!
I'm also thinking of dabbling in a variety of allocators; that way I can use the one that best fits what I'm looking for.
No comments:
Post a Comment