I am currently using Visual VM to monitor the heap memory usage of my Java application. However I would like to somehow see the heap memory usage over a span of time like for ex
Try the Memory tab in JConsole. JConsole is also included with the Oracle JDK, like JVisualVM, so you should already have it. It has a time range of "all" which should work for what you want to do. It will look like this:
Run your Java program with the following Java options:
-Xloggc:log.out -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
and download HPjmeter to visualize log.out
.
Also see SUN's GC portal webpage for more options to run with. Since the data is written to a file, you won't have any problems collecting days or weeks worth of data. Of course, if you wish to visualize data with lots of information, you'll need to run HPjmeter with more memory.
Your other option is to use JConsole.