Added clear method to make sure all objects are destroyed.
p4#: 20828