We wanted to evaluate java performance on IBMi machine and I am very to the IBMi world. I am running java program to perform database CRUD operations on IBMi machine to know the performance. To evaluate the performance we are capturing memory usage by capturing before and after usage by using below java code –
I am running program by using below two ways –
- QSH – Inbuild IBMi shell
- Using IBMi batch job
How we calculate memory usage is –>
long initialMemoryUsage = getMemoryUsage();
After getting initial memory usage I am performing some DB read operations for 1,00,000 records
long memoryUsageAfter = getMemoryUsage() - initialMemoryUsage // (initial memory captured);
private static long getMemoryUsage() {
Runtime runtime = Runtime.getRuntime();
return runtime.totalMemory() - runtime.freeMemory();
}
However sometimes I am getting negative numbers for memory usage. Anyone aware about reason behind this? Please correct me if I am using wrong way to capture the memory usage
Thanks in advance.
Ideally I should get positive memory usage numbers on IBMi world. Here problem is I am very new to IBMi world and not sure how memory works here. If anyone aware about it please feel free to share.
Nitin Chemate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.