On 14/03/17 20:44, Hans Boehm wrote: > It's not hard to add an API to tell the garbage collector to pretend > that you're holding onto those 18GB of additional memory when it > decides whether to collect, without actually actually holding onto > all of that memory.
It may not be hard to add the API, but actually adding a check for such a flag in the hot path of the collector would be very unpleasant. But what would we do instead? I guess the best trick would simply be never to promote them. Then they'd get freed at minor collections, rather than only at full collections. The main problem seems to be generational collectors; non-generational ones, in practice, seem to work just fine. I'm sticking to my position: it's no more appropriate to manage such native resources with GC than it is file handles. If Java had never had finalizers people would have figured out better ways to manage such resources: what we have here is a legacy issue. Andrew.