Given a length function L on the R-modules of a unital ring R, for each sofic group $Gamma$ we define a mean length for every locally L-finite $RGamma$-module relative to a bigger $RGamma$-module. We establish an addition formula for the mean length. We give two applications. The first one shows that for any unital left Noetherian ring R, $RGamma$ is stably direct finite. The second one shows that for any $ZGamma$-module M, the mean topological dimension of the induced $Gamma$-action on the Pontryagin dual of M coincides with the von Neumann-L{u}ck rank of M.