The main answer to the question is as follows: don't make circular references. If you think you might accidentally make them, then don't use ExpressionStore.
However, if through some unfortunate coding choices, you think you have circular references, just clear out everything from the store.
You can manually clear an expression store using something like
store["remove"[#]] & /@ store["listTable"[]][[All, 1]];
I like the functionality you get with the expression store, but I very much dislike the syntax for using them. So I made a wrapper called WeakHashTable
with a syntax closer to the "HashTable"
data structure.
Using that function you would do something like
table = WeakHashTable["example table 1"]
(* define a and b *)
table["Insert", a, "key", b]
table["Insert", b, "key", a]
(* realize you have a leak *)
table["KeyDropAll"]