# Documentation missing for SCRIPT GC

**URL:** <https://dragonfly.discourse.group/t/documentation-missing-for-script-gc/216>\
**Category:** General\
**Created:** [October 2, 2024, 4:35pm UTC](https://dragonfly.discourse.group/t/documentation-missing-for-script-gc/216 "2024-10-02T16:35:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![intj9839](https://avatars.discourse-cdn.com/v4/letter/i/ed655f/32.png) [@intj9839](https://dragonfly.discourse.group/u/intj9839)\
**Post date:** [October 2, 2024, 4:35pm UTC](https://dragonfly.discourse.group/t/documentation-missing-for-script-gc/216/1 "2024-10-02T16:35:59Z")

</div>

> <https://github.com/dragonflydb/dragonfly/pull/3431>
>
> Adds SCRIPT GC command to invoke GC and a simple test

Hi,  
Can you explain to me how/when to use this and whether this is enabled by default on the new version?

Thanks

---

<div class="post-metadata">

**Author:** ![joezhou\_df](https://yyz2.discourse-cdn.com/flex004/user_avatar/dragonfly.discourse.group/joezhou_df/32/82_2.png) [@joezhou\_df](https://dragonfly.discourse.group/u/joezhou_df)\
**Post date:** [October 7, 2024, 3:04pm UTC](https://dragonfly.discourse.group/t/documentation-missing-for-script-gc/216/2 "2024-10-07T15:04:56Z")

</div>

Hi there! 👋

This command is used to instruct the Lua script engine instances to perform a GC. I am not sure when to use it though, but I am thinking normally we should not bother using it unless something heavy happens on the Lua engine. I will ask an engineer to take a look at this thread as well!

The `SCRIPT HELP` command has some explanation as well:

```shell
dragonfly$> SCRIPT HELP
 1) SCRIPT <subcommand> [<arg> [value] [opt] ...]
 2) Subcommands are:
 3) EXISTS <sha1> [<sha1> ...]
 4) Return information about the existence of the scripts in the script cache.
 5) FLUSH
 6) Flush the Lua scripts cache. Very dangerous on replicas.
 7) LOAD <script>
 8) Load a script into the scripts cache without executing it.
 9) FLAGS <sha> [flags ...]
10) Set specific flags for script. Can be called before the sript is loaded.
11) The following flags are possible: 
12) - Use 'allow-undeclared-keys' to allow accessing undeclared keys
13) - Use 'disable-atomicity' to allow running scripts non-atomically
14) LIST
15) Lists loaded scripts.
16) LATENCY
17) Prints latency histograms in usec for every called function.
18) GC
19) Invokes garbage collection on all unused interpreter instances.
20) HELP
21) Prints this help.

```

---

<div class="post-metadata">

**Author:** ![dranikpg](https://yyz2.discourse-cdn.com/flex004/user_avatar/dragonfly.discourse.group/dranikpg/32/68_2.png) [@dranikpg](https://dragonfly.discourse.group/u/dranikpg)\
**Post date:** [October 7, 2024, 5:10pm UTC](https://dragonfly.discourse.group/t/documentation-missing-for-script-gc/216/3 "2024-10-07T17:10:00Z")

</div>

Hi!

Because lua uses garbage collection, not all freed memory is instantly reclaimed. This is a command that you can call manually to run lua’s garbage collector. To avoid runtime penalties, we don’t call it manually when a script finishes execution, it only get’s to run from time to time when new allocations happen
