I am trying to use the freeMemory() of Runtime object to determine the available memory in JVM, so I wrote a simple program to allocate some memory, then free them and call GC to notify system to collect them. Ideally, most allocated memory should be collected by GC. However, every time there are always about half of the memory uncollected, and I don't know if it is the problem of freeMemory() or the GC process! Could someone please take a look at the program below and tell me why the result?
Thanks a lot for your help!
I was using Eclipse to run the program and the result was like:
[ added code tags
- Jim ]
[ January 18, 2007: Message edited by: Jim Yingst ]