Menu

#204 Resource Error on Interned Tries

Other
open
None
5
2013-09-08
2013-09-08
No

| ?- basics:for(I,1,10000), storage:storage_insert_fact(aaaa,fact,_), storage:storage_delete_all(aaaa), fail.
++Error[XSB/Runtime/P]: [Resource (interned tries)] in predicate newtrie/1)

FYI, storage_delete_all is finding a trie handle and then calling delete_trie(H).

--
I found the problem, but don’t know the best way to fix it. Maybe Terry does.
The problem is in get_storage_handle in storage_xsb.c. It detects that it needs to get a new trie by checking if (handle_cell->handle==(Cell)0). The problem is that when a trie becomes empty (by deleting the last fact in it) that field is set back to 0. So since your example deletes the last (and only) fact each time, it gets a new trie each time, instead of using the same one, and then runs out of potential tries (which are limited.) So to fix this, we need either (a) a way to detect that the trie was actually found (but I don’t see in the hash lookup code an easy way to detect that, without changing a lot), or (b) deleting the trie when it becomes empty, so that its space is available when it gets reallocated.
Maybe Terry can find the easiest way to do this.
-David

Discussion


Log in to post a comment.