It does not run out of numbers, the name is variable length so it will spill to 5+ digits if needbe. It's 4 digits by the way - 1 to 9999.
tdbcompact
create a new storage area which only contains the "in use" RDF data. TDB2 does not clear up all freed space as deletes happen, only some of the space - it is a trade-off of efficiency against needing to peform, for example, reference count literals and URIs actually used in the data.
Once migrated to a new storage area, the old area is not used at all. You can archive it, delete it, or file-compress it - whatever you want to do.
As a database is updated, it grows so occasionally compacting it and then deleting the old storage frees up persistent storage.