Is there a way to see the maximum working memory of my code?

@time gives the total memory allocation of a piece of code, but because of garbage collection I can have code that allocates much more memory than my system has RAM. Is there a way to see the maximum working memory of a piece of code (i.e., the minimum amount of RAM a computer will need to be able to run the code)? (I need to know how much memory to request from a computing cluster.)