The idiomatic way to do this is to dupe the strings on their way into the ArrayList so that pointer ownership is clear. Or, alternatively, to limit caller to passing comp time values so cleanup is unnecessary. Not fancy, but that's kind of the point.