In Tez, when there is container reuse, static variables, thread locals, etc have to be reinitialized to avoid memory leak or having wrong values. For the short term, we ended up making some of the static variables public or adding destroy method to each class which is hacky. Also it does not help users who will want something similar to be done in their UDFs or LoadFunc. Need to define a interface with a reset/destroy method and find all loaded classes implementing that interface and call destroy on them in PigProcessor.close(). ServiceLoader and annotations are some of the ways to find classes implementing an interface and there are other libraries as well. Need to find the best and fastest way to do that.