views:

128

answers:

1

I have an application that writes some data (about 15mb in 80k tuples) into an SQLite database using this jdbc-driver on Mac OS X. This is done using transactions, the largest of which contains about 45k inserts into one table. When profiling the application, several things seems strange:

  1. If I pause the application right at the beginning using System.in.read(), the memory allocated by the process keeps growing slowly. Why is that?
  2. When the application runs, the heap space used is always at around 80mb in the VisualVM monitor. However, when profiling memory usage, I get a total of about 10mb. Can anyone explain this difference?

Thanks for any help.

A: 

With regards to your first issue, how long of a time slice did you observe the slow growth over. When memory usage is quiescent in a Java process you'll typically see a jigsaw pattern develop. Did you see any GC's occur in the same time slice? If not, then thats more evidence that supports this idea.

For problem number two, it's really hard to say for certain without more information. You would typically expect the application behaivor to differ when profiling is turned on because timing windows change, the application has to spend time reporting data and doing its normal work, etc. It could be that when profiling is turned on, more memory allocations happen because your code is now instrumented, and this triggers a GC which lowers the heap usage. Try doing a System.gc() in your application when profiling is turned off and tell us what your heap usage reports.

Amir Afghani
With or without profiling, the application always runs into an out-of-memory error, so I guess the high heap-usage is correct.
Space_C0wb0y
OK, so the next step is to take a heap dump and interpret the results. You can do this with VisualVM or JConsole. Open the resulting heap dump file using Eclipse MAT or HPjmeter and see whats being kept in memory.
Amir Afghani