Availability:C-language interface function
- Do not reclaim memory. This is the default when called from PL_halt() for the release versions because the OS will do so anyway.
- Do not allow Prolog and foreign halt hooks to cancel the cleanup.
The return value of PL_cleanup() is one of the following:
- A Prolog or foreign halt hook cancelled the cleanup. Note that some of the halt hooks may have been executed.
- Cleanup completed successfully. Unless
PL_CLEANUP_NO_RECLAIM_MEMORYwas specified this implies most of the memory was reclaimed and Prolog may be reinitialized in the same process using PL_initialise().
- Cleanup failed. This happens if the user requested to reclaim all memory but this failed because the system was not able to join all Prolog threads and could therefore not reclaim the memory.
- PL_cleanup() was called from a hook called by the cleanup process.
PL_cleanup() allows deleting and restarting the Prolog system in the same process. In versions older than 8.5.9 this did not work. As of version 8.5.9, it works for the basic Prolog engine. Many of the plugins that contain foreign code do not implement a suitable uninstall handler and will leak memory and possibly other resources. Note that shutting Prolog down and renitializing it is slow. For almost all scenarios there are faster alternatives such as reloading modified code, using temporary modules, using threads, etc.