Topic: evaluating memory usage of a method?

I am working on writing a method that creates a CSV file using data from a number of associated tables. We have tried to use plugins in the past to do this, but because the data sets are quite large, the plugin would max out the memory available on our web app box and crash the app.

I have finished writing a custom method, but I would like to test how much memory the method is consuming before I place it in production. Any one know which tool(s) would be best for this?