# Module unload/delete

**URL:** https://swi-prolog.discourse.group/t/module-unload-delete/7222
**Category:** PlDoc
**Tags:** how-to
**Created:** [February 5, 2024, 4:38pm UTC](https://swi-prolog.discourse.group/t/module-unload-delete/7222 "2024-02-05T16:38:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nobleg](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@nobleg](https://swi-prolog.discourse.group/u/nobleg)
#### Post date: [February 5, 2024, 4:38pm UTC](https://swi-prolog.discourse.group/t/module-unload-delete/7222/1 "2024-02-05T16:38:19Z")

</div>

I am sure i have missed the obvious,… but if i have loaded a large module, but then dont need it anymore, how do I unload / delete the module so resources can be returned to the core ! … Ready to be embarrassed

---

<div class="post-metadata">

### Author: ![Boris](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/boris/32/7486_2.png) [@Boris](https://swi-prolog.discourse.group/u/Boris)
#### Post date: [February 5, 2024, 6:56pm UTC](https://swi-prolog.discourse.group/t/module-unload-delete/7222/2 "2024-02-05T18:56:17Z")

</div>

This is one thread that seems to try and answer your question: [Re-defining a predicate in a new module file, vs. in a traditional file](https://swi-prolog.discourse.group/t/re-defining-a-predicate-in-a-new-module-file-vs-in-a-traditional-file/3491/1)

The short answer seems to be, no, you cannot truly unload a module. But there seem to be workarounds depending on the use case?

What is in your large module? If it is data, you could probably read the file and assert its contents; then retract them when you no longer need it. This will get garbage collected.

Apparently there is also in\_temporary\_module/3 here: [modules.pl -- Module utility predicates](https://www.swi-prolog.org/pldoc/doc/_SWI_/library/modules.pl)

---

<div class="post-metadata">

### Author: ![nobleg](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@nobleg](https://swi-prolog.discourse.group/u/nobleg)
#### Post date: [February 5, 2024, 8:30pm UTC](https://swi-prolog.discourse.group/t/module-unload-delete/7222/3 "2024-02-05T20:30:24Z")

</div>

Thanks,…

yes im thinking ill have an empty predicate to retract all as you said…

next point of thinking is if i want re open it i have to reuse the module name. thinking ill just use modules and have an empty and fill predicate,…
