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.
1 comment:
Hi,
i first used this feature under nextstep / mach. It was called a zone. So an object (in objective-C) created a zone and all its child objects could be allocated from that zone .. and so forth .. and you could free a complete zone.
Take a look at:
http://www.channelu.com/NeXT/NeXTStep/3.3/nd/Concepts/Performance/F_ZoneAllocation.htmld/index.html
that might give you an impression.
It was (maybe it is still in MacOS X) a nice solution
Post a Comment