void (@NotNull VirtualFile vf, RangeMarker @NotNull [] marker, RangeMarker @NotNull [] persistentMarker) { Reference<RangeMarker> markerRef = new WeakReference<>(marker[0]); Reference<RangeMarker> persistentMarkerRef = new WeakReference<>(persistentMarker[0]); marker[0] = null; persistentMarker[0] = null; PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); while (markerRef.get() != null || persistentMarkerRef.get() != null) { GCUtil.tryGcSoftlyReachableObjects(); UIUtil.dispatchAllInvocationEvents(); } DocumentImpl.processQueue(); UIUtil.dispatchAllInvocationEvents(); assertNull(vf.getUserData(DocumentImpl.RANGE_MARKERS_KEY)); assertNull(vf.getUserData(DocumentImpl.PERSISTENT_RANGE_MARKERS_KEY)); }