Memory management and persistency of multithreaded applications