# ERROR: Not enough resources: table\_space - How can I increase table space?

**URL:** <https://swi-prolog.discourse.group/t/error-not-enough-resources-table-space-how-can-i-increase-table-space/1682>\
**Category:** General\
**Created:** [January 1, 2020, 2:06pm UTC](https://swi-prolog.discourse.group/t/error-not-enough-resources-table-space-how-can-i-increase-table-space/1682 "2020-01-01T14:06:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [January 1, 2020, 2:06pm UTC](https://swi-prolog.discourse.group/t/error-not-enough-resources-table-space-how-can-i-increase-table-space/1682/1 "2020-01-01T14:06:23Z")

</div>

Happy New Year all!

```prolog
ERROR: Not enough resources: table_space
^ Exception: (38) catch('$tabling':create_table(<trie>(0x1ebcc60), ret(_526782, _526784), user:move(_526782, _526784
), evaluation:call(<closure>(move/2)(_526782, _526784))), deadlock, '$tabling':restart_tabling(<closure>(move/2), use
r:move(_526782, _526784), evaluation:call(<closure>(move/2)(_526782, _526784)))) ? creep

```

I’m getting this error probably because I’m doing something silly and trying to table a predicate with a definition that really shouldn’t be that large. Until I can find the source of the problem and fix it at the root, how can I increase table space?

I know there is a command line option for that, `--table_space=Size`, but can I do it with a directive from inside a source file?

Edit: Additionally, what predicates can I use to get information about tables, like their size or currently tabled predicates and so on?

Cheers,  
Stassa

Edit: added a bit more error context.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [January 2, 2020, 9:23am UTC](https://swi-prolog.discourse.group/t/error-not-enough-resources-table-space-how-can-i-increase-table-space/1682/2 "2020-01-02T09:23:04Z")

</div>

> [@stassa.p](#):
>
> I know there is a command line option for that, `--table_space=Size` , but can I do it with a directive from inside a source file?

```
?- set_prolog_flag(table_space, <Bytes>).

```

> [@stassa.p](#):
>
> Additionally, what predicates can I use to get information about tables, like their size or currently tabled predicates and so on?

That is a field that is developing. Currently there are two ways. One is using my [personal Prolog lib](https://github.com/JanWielemaker/my-prolog-lib), to be installed in `~/.config/swi-prolog/lib` (see also the README.md of the repo for installation instructions). In this library you find `tstat.pl` and `tdump.pl` with several utility predicates.

The second route is to use [WebStat](https://github.com/SWI-Prolog/webstat.git), which provides a web interface for exploring (currently notably) table related statistical information. Eventually this should grow to a full blown web UI to explore just about any aspect of your program. Help is welcome!

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [January 2, 2020, 10:36pm UTC](https://swi-prolog.discourse.group/t/error-not-enough-resources-table-space-how-can-i-increase-table-space/1682/3 "2020-01-02T22:36:53Z")

</div>

Happy New Year, Jan!

```prolog
?- set_prolog_flag(table_space, <Bytes>).

```

Thanks! I should have tried that on my own, but somehow I managed to miss it when I looked at the documentation online a few days ago.

Btw, I managed to eliminate the error. Unfortunately, I am not sure exactly what did it. I made a change where, before, I would call untable/1 inside the cleanup “block” of a setup\_call\_cleanup/3 call. On a hunch, I _copied_ the untable/1 call inside the call “block” of setup\_call\_cleanup/3.

So my code was originaly like this:

```prolog
S = (table(F/A)
     % other setups
     )
,G = % main goal
,C = (untable(F/A)
      % other cleanup
      )
,setup_call_cleanup(S,G,C)

```

And now it’s like this (and it doesn’t raise the error anymore):

```prolog
S = (table(F/A)
     % other setups
     )
,G = ( % main goal
      ,untable(F/A)
     )
,C = (untable(F/A)
      % other cleanup
      )
,setup_call_cleanup(S,G,C)

```

Is it possible this did something to avoid the error? I noticed the exception said something about a deadlock.

Cheers,  
Stassa

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [January 3, 2020, 9:23am UTC](https://swi-prolog.discourse.group/t/error-not-enough-resources-table-space-how-can-i-increase-table-space/1682/4 "2020-01-03T09:23:54Z")

</div>

I don’t know. Note that dynamically switching on/off tabling for a predicate is a pretty weird thing to do. It might be that SWI-Prolog is the only implementation that allows you to do so (and as most test cases come from XSB, it is not tested much). Can you produce a test case? What are you trying to accomplish?

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [January 3, 2020, 2:31pm UTC](https://swi-prolog.discourse.group/t/error-not-enough-resources-table-space-how-can-i-increase-table-space/1682/5 "2020-01-03T14:31:12Z")

</div>

It seems I was a bit hasty about having eliminated the error because it looks like it happened again (I couldn’t collect the output but my code exited before it should and I’m guessing that’s the reason).

I’m not sure about a test case. I’m running an experiment comparing two ILP algorithms on the same dataset and running the same experiment code and evaluation code. The tabling/untabling is in the shared evaluation library. One algorithm is erroring out of table\_space most likely because it’s producing a very large result, on the order of a couple thousand clauses that is then tabled (the result is a learned program that may include left-recursive clauses which I table to avoid it entering an infinite recursion before evaluation).

It’s hard to produce a test case because the error seems to happen at the very end of the experiment and tests on shorter runs that also produce the same size of learned program do not raise the error (which makes me suspect some kind of memory leak, either in my code or, well, yours).

What I could do is to add you as a collaborator to the private github repository for the experiment code that includes everything you need to run it and reproduce the error. It includes a bash script that runs the experiment plus two other experiments that don’t cause the same trouble. You can run the errorring experiment in isolation by commenting out a few lines on the script, which I’ll explain.

Would that work? Otherwise I can always try to increase table space… It’s just that the full experiment can take a while (I think about half to one hour, I haven’t been timing it precisely).
