Is there a way to track a programs memory usage so I can make sure I don't have a memory leak issue?

What I'm hoping for is some sort of function like mem_usage() or something that will return the amount of memory my program is using.