Added API to get memory usage in Code

This would further help in tracking the optimization after using
recursion