Availability:C-language interface function
status_and_flags)This function may be called instead of PL_halt()
to cleanup Prolog without exiting the process. It performs the reverse
It runs the PL_on_halt()
handlers, closes all streams (except for the standard I/O
streams, which are flushed only), restores all signal handlers and
reclaims all memory unless asked not to. status_and_flags
accepts the following flags:
- 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
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
was 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
was called from a hook called by the cleanup process.
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.