Add ability to use custom memory management functions

This feature was available in legacy version. It allows to use memory managers like ScaleMM.