is there any method that can calculate memory usage when sorting other than getHeapMemoryUsage().getUsed(); from import java.lang.management.ManagementFactory; and im wondering getHeapMemoryUsage().getUsed(); getNonHeapMemoryUsage().getUsed(); calculate the memory used in Byte? thx
Asked
Active
Viewed 204 times
1 Answers
3
You can use a memory profiler to measure how much memory is used.
IMHO Its best to calculate it by reading the code. Many sorting alorithms don't use any additional heap memory. ;)

Peter Lawrey
- 525,659
- 79
- 751
- 1,130
-
(well, technically... :-) no memory which is dependant on the size of the array being sorted) +1 for the memory profiler though, I fully agree. – Jaco Van Niekerk Mar 29 '12 at 06:57
-
1Sorry, no heap space. They all use some stack space. ;) If you are sorting an array or list, in place it shouldn't need any additional heap space no matter how big it is. – Peter Lawrey Mar 29 '12 at 07:02