My Linux system sometimes reaches 90% memory usage.

We are running some Java processes, and top shows overall usage as 45%.
If I stop the running processes, usage reduces to 5-10%. I want to list out which process is consuming so much memory, ideally as a table of process ids next to their memory usage.
How can I do that?