I call TDirectoryFile::GetObject(), passing a TDirectory pointer. In some cases the name I am attempting to fetch exists in the file, but instead represents a TTree. I get a null pointer returned, as expected, but there is also a large memory leak (a few megabytes).
I have worked around this by simply calling Get() and using GetClassName() to do the type checking manually. But the version with GetObject( ) was more convenient.
I don't know if this problem is confined to TDirectory/TTree, or would happen with any mismatched pair of types.