Change the contract of ResourceLeakDetector.open() so that unsampled resources are recycled

- This also fixes the problem introduced while trying to implement #1612 (Allow to disable resource leak detection).