Custom memory pool.
Hi!
I have been studying different ways to implement object cache for server application(s). At the server there areXML files which have to be parsed and validated before delivering to clients. Clients are also sendingXML data back to be validated and stored by the server. It would be nice to have object cache between servlets and IO to make server run faster. The ultimate requirement for cache is:There have to be way to set upper limit for caches memory footprint to avoid OutOfMemory.
I found couple of third parties object caches likeJava Caching System (JCS), OSCache, Commons Collections, JCache API but none is supporting cache policy to fulfil my requirement. Am I right? Is there any others? (Open Source)
I started also desining my own implementation of object cache but the problem is:How to calculate object size in bytes.
I tried to solve problem by creating interfaceCacheable that contains methodsizeOf(). It is quite easy to implement and calculate approx size of (simple data) object exceptString. I wrote my on custom String class to get size. I also wrote someCacheable implementations of collection classes too. But next problem was that (object) cache become too specific.
Okey, nowJMX questions : )
1. Question is: Is it possible to useJMX to create totally new memory pools within sameVM for object cache.Why? It would be easy to examine memory usage of cache by examining memory usage of those pools.
2. Is there way to set a classloader to load certain classes to those memory pools.
3. Is it possible to set a "rule" that instances of those classes are placed also into new pools.
4. DoesJMX inspection have some severe performance drawbacks?
Plan B
I have also considered idea of running object cache as independentservice in its ownVM. And connecting to it byRMI. Any comments? Performance issues? Have anybody done this?
Thanks!

