Can't answer for linux but on Windows it's easy enough the OS actually provides this as API calls...
Heap Functions (Windows)
Basically you create a private heap... but it also gives you far better functionality than malloc() and free()... for example you can discover the size of any memory block with HeapSize() and you can confirm HeapFree() with HeapValidate()...
I've often noticed that people seem naturally prone to go in the wrong direction ... they avoide the OS and it's first level APIs like they're going to die if they use them, when in fact getting closer to the core OS very often reveals increased power and capability.