On Die, 2004-05-18 at 16:28, Todd Wright wrote: > > > What I'm doing is to put all the objects in a hash table. That means > > > you can associate whatever info you want with them. You have to > > > make sure that you use System.identityhashcode and the == operator, > > > you have to use weak references (unless you don't mind no garbage > > > collection occurring) and you have to be careful that your own > > > objects (eg the WeakReferences themselves) don't get put into the > > > system. > > > > > > Apart from that it's quite simple. :-) > > > > I was thinking about this approach too. There's a high probability that > > I will try it this way now. > > Thanks for pointing out the difficult parts! > > I wrote something like this using BCEL without VM changes. It's all open > source: > > Offline I modify all class constructors to register the newly created instance > in a table, using WeakReferences to allow GC: > http://profiler.cougaar.org/#design > For and overview and snapshots, see: > http://profiler.cougaar.org/ > I implemented a table that's quite similar to your design: > http://cougaar.org/cgi-bin/viewcvs.cgi/profiler_impl/src/org/cougaar/profiler/InstancesTable.java?rev=HEAD&cvsroot=profiler&content-type=text/vnd.viewcvs-markup > > It was discussed on the "advanced-java" mailing list: > > http://discuss.develop.com/archives/wa.exe?A2=ind0312&L=ADVANCED-JAVA&T=0&I=-3&P=1321 > > Since the above discussion I've fixed several limitations, such as String and > Thread tracking. Some "java.lang" classes are still out of reach due to the > VM: > Class > Object > String$CaseInsensitiveComparator > java.lang.ThreadGroup > java.lang.Throwable > java.lang.ref.Reference > java.lang.ref.SoftReference > java.lang.ref.WeakReference # since I use WeakReferences in my table! > The Sun JVM ignores any modifications to Class, and Object is likely the same, > since it's partially built into the VM. Also, there was a minor hurdle with > BCEL 5.1 and "java.math.BigInteger": > http://issues.apache.org/bugzilla/show_bug.cgi?id=18323 > > A more significant limitation is array tracking, since arrays lack a > constructor. I've started a workaround to modify "newarray" clients, but > some of the largest arrays are inside the JVM (e.g. classfile bytecodes, > jars, string constants, etc). > > I'd be happy to discuss the details and usage...
I don't have any of these problems, since I can put these things into the compiler. I only have to be carefull with regards to GC. Thanks for your help! -- Daniel --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
