Abstract: A method, including receiving a request to migrate an executing application (34) that includes a library (42) having functions (46) configured to generate a log (92) tracking library resources (106). Upon suspending the application while the library has a current state (160), the library is unloaded from memory (24), and upon unloading the library, any pending resources allocated to the library are identified. The identified resources are deallocated so as to define a cleaned version of the application that does not include any of the allocated resources, and the cleaned version of the application is migrated to a destination machine (180). Execution of the migrated application is resumed on the destination machine so as to link the migrated application to an additional instance of the library, and the log is replayed so as to bring the linked additional instance of the library on the destination machine to the current state.