When TMC error comes up, it automatically restarts the java. I've found that restarting the java resets the memory and yeah. So maybe it's possible?