void () { final Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]"); Set<RangeMarker> markers = new HashSet<>(); for (int i = 0; i < 10; i++) { markers.add(document.createRangeMarker(0, document.getTextLength())); } LeakHunter.checkLeak(document, RangeMarker.class, markers::contains); }