TFile size stays large after Purge()

Dear ROOT experts,

I’m playing with a some code that sometimes writes histograms to a TFile with new cycle numbers, and then sometimes Purge()s old ones.

First, I discovered that Purge() only works on the current directory, and had to write code to recursively loop over sub-directories in a file.

Second, I was surprised to discover that the file size was basically unchanged after a Purge() operation. Although the older cycles disappeared from the file index, the unused space was not recovered, and the file size was still large.

Assuming I want to continue this route, how can I recover the disk space? Is there a convenient way to re-compact the file, or failing that, copy the entire file to a fresh, defragged one?