posted 22 years ago
Mike,
Not that I know of. You can create your own class ReferenceNew {} which wraps and returns you an actual. Within this ReferenceNew class, you can maintain a count of objects you created with new. It's easy if you want to keep a count of objects allocated since your program started, but it gets more complicated if you want to keep an accurate count of what objects are still active and the number objects that have been collected. Then you'll have to do some fancy stuff with the finalize() method, which I don't recommend doing unless you really need it.
You can look at the various profilers for Java. They do a very good job of keeping reference counts.
-Peter