$count = $session->countInstances( )

The countInstances() function counts the total number of objects in the repository, of all classes.

 $n = $session->countInstances( );