public static void assertNoWorkspacesOpen ( String msg ) throws ND4JWorkspaceException { if ( Nd4j . getWorkspaceManager ( ) . anyWorkspaceActiveForCurrentThread ( ) ) { List < MemoryWorkspace > l = Nd4j . getWorkspaceManager ( ) . getAllWorkspacesForCurrentThread ( ) ; List < String > workspaces = new ArrayList <> ( l . size ( ) ) ; for ( MemoryWorkspace ws : l ) { if ( ws . isScopeActive ( ) ) { workspaces . add ( ws . getId ( ) ) ; } } throw new ND4JWorkspaceException ( msg + " - Open/active workspaces: " + workspaces ) ; } }
Assert that no workspaces are currently open