Skip to content

Memory Leak in pythonic interface #119

@zwilling

Description

@zwilling

Dear maintainers,

there seems to be a memory leak when using the pythonic interface.

Running the following script similar to the readme example

from pyswip import Functor, Variable, Query, call
import time

assertz = Functor("assertz", 1)
father = Functor("father", 2)
call(assertz(father("michael","john")))
call(assertz(father("michael","gina")))

start = time.time()
while time.time() < start + 20:
    X = Variable()
    q = Query(father("michael",X))
    while q.nextSolution():
        print("Hello,", X.value, time.time())
    q.closeQuery()

leads to this memory usage (measured with mprof run pyswip-memleak.py):
pythonic-memleak

I am using pyswip==0.2.10 with SWI-Prolog version 7.7.10 and Python 3.5 on Ubuntu 18.04.

It would be great if you can fix this because the pythonic interface allows simple processing of the solution compared to string queries which have to be parsed first.
Lio would be thankful for your help: Lio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions