10.6.5.3 Memory Leaks

In order to avoid memory leaks, environments, databases and iterators should always be closed explicitly. Consider using call_cleanup/2 to automate the closing/deallocation of these objects. You can always use db_current_env/1, db_current/5 and db_current_iterator/3 to enumerate the currently living objects.

Please note: a database must not be closed while there are outstanding choices for some db_fetch/3 goal that refers to that database. Outstanding choices can be removed with a cut (!).

Send feedback on this subject.