prof: add gc statistics hook, add getHeapStatistics() function

Refs #6414.