I've been working on a garbage intensive java application that does lots of EDI and XML translation. Reading XML and mapping objects creates lots of garbage quite quickly and the JVM spends a fair amount of time clearing up garbage. It seems that some sort of pool would help in this case. I would think this could be useful for lots of transactional and web based systems.
How it would work is another matter. Perhaps a "pool context" could be associated with a thread.
The garbage collector would not see foo or bar. It would only see and collect from pool.It's more complicated than that, though, since you could allocate
MemoryPool pool = Runtime.createMemoryPool();
Thread.currentThread().setMemoryPool();
Foo foo = new Foo(); // allocated in pool
Bar bar = new Bar(); // allocated in pool
something in the pool and then assign it to a variable (for example,a Map) outside of the pool.
HashMap map = new HashMap();
MemoryPool pool = Runtime.createMemoryPool();
Thread.currentThread().setMemoryPool();
Foo foo = new Foo(); // allocated in pool
map.put("Foo", foo);
In this case the garbage collector would see foo.
The compexity probably outweighs any real benefits, but I find the idea interesting either way.