Hi, >I am wondering if there is any "short-cut" into seeing how much memory each >webapp in tomcat is taking at runtime ? >I know it's possible to wrap the classloader object for webapplications, >and make it count the numbers of objects instanciated, aproxiate the memory >taken by each object by counting the fields each object has, and store in >week-reference object storage (such as week hashmap), and count down when >object gets garbagecollected.
This is basically what profilers do ;) >The idea is some kind of a "profiling feature" for webapplications and I >think a nice feature to have. It would be a nice feature to have, I agree. >Does anyone have thoughts or ideas on this subject ? Like most really nice features, this is a pain to implement. Hierarchical memory usage is very very difficult to quantify. For example, you can see that there are n String objects in the heap, and you can approximate (but being exact is very difficult here, and I do think it comes to a point where we have to be exact) how much memory they take up collectively. You can go a step further using the JVMPI and get allocation backtraces, e.g. x of these n strings were allocated by this method. And you can then some those up with by webapp using your approach, to get some idea of the memory usage by a webapp. So this solution, which is not trivial to implement will be: - Unlikely to give accurate results, only approximations of varying precision (according to data type and other variables). - Likely to significantly decrease performance of the running webapp, enough so that it couldn't be used in production. I'm not saying it's a bad idea: I'm just sharing my thoughts as requested ;) It'd a be a cool feature to have and I think we collectively need to do more in terms of providing profiling and benchmarking tools, options, and data to our users. But it's not an easy domain to work in ;) Yoav Shapira Millennium ChemInformatics -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>