setAutoSave() questions

I created a tree (t1) in my codes, and I used t1->setAutoSave(1000). But I found it didn’t work at all. If I didn’t use t1->Write(), the tree is never saved to my file. If I used t1->Write() at the end of my codes, the key of the tree was always one, which means it was never autosaved. Could anyone please tell me why?
I think it’s not of the problem of my file size, which is big enough and my setting 1000 is small enough.
Thank you!

Could you indicate your version of ROOT and send the shortest possible running script reproducing the problem?