× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



albartell wrote:

The problem:
As you can see I have a output statement that calls on
Runtime.getRuntime().freeMemory() used to see how much memory is available
at each asyncMethod(...) execution. The freeMemory() return value starts out
at about 15MB and continues to go down to 2MB and at that point the JRE
running on the device seems to think it is time to run GC and the
freeMemory() is bumped back up to 15MB.  I have attempted to put in
System.gc() statements to do my own garbage collection, but that doesn't
seem to address the problem (or rather it doesn't affect the value I am
getting from freeMemory()).


You are not guaranteed that system.gc() actually do anything. It is a hint. If you do not want garbage collection you should reuse your objects yourself instead of creating new one every time. This is usually well described in Java performance articles. Note that new is traditionally an expensive operation.

But what is the problem? If the garbage collection results in all the memory you expect being available - and you don't mind the pause - then you are home free. The problem would be if you leak memory e.g. if you still have references to old objects lingering around. This is usually found with a profiler - doing so manually is a pain.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.