So, what I think the JVM needs is an extensible concept of resources... for example, sun could add to the System class the following method:
public static synchronized void incrementResourceUsage( String resourceName, int amount );
The "amount" is generic... it is compared only to thresholds that can be set on the command-line, or in a properties file. So, when you instantiate FooBar, it increments the resource "foobar" the appropriate amount. If a threshold is exceeded, it causes garbage-collection, which will hopefully reduce the amount of the "foobar" resource in use. The finalize method for FooBar would increment the same resource by the appropriate negative amount.
(This example is bad, because you normally wouldn't want the resource
to be class specific... for example you would have a resource for memory
allocated outside the JVM's heap (a wrapper for malloc() and free() would
be the way to go, for the legacy code example), a resource for x-server
resouces held, etc.)
-- ---------------------- Rob Clark Dot Wireless, Inc. (858)552-2946 [EMAIL PROTECTED] ----------------------