It has certainly been done in various Java implementations. HotSpot I'm pretty sure does precise garbage collection.
Native stacks don't need to be scanned for pointers, but the VM must of course keep track of which parts of the stack are native.
It has certainly been done in various Java implementations. HotSpot I'm pretty sure does precise garbage collection.
Native stacks don't need to be scanned for pointers, but the VM must of course keep track of which parts of the stack are native.
But those few objects referenced directly may keep a lot of other stuff alive. It's not that uncommon to have left-over pointers on the stack that are no longer live, but still reference a large graph of objects.
Edit: you can do stop-the-world GC at any point of program whan you scan stack conservatively, GC-safe points are only needed for precise scanning of stack and registers, so this is problem only when you want to be fully precise. Fully precise GC is certainly better when it is possible, but conservative scan works mostly well enough.