Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak in pythonic interface #119

Open
zwilling opened this issue Mar 12, 2021 · 1 comment
Open

Memory Leak in pythonic interface #119

zwilling opened this issue Mar 12, 2021 · 1 comment
Milestone

Comments

@zwilling
Copy link

zwilling commented Mar 12, 2021

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

@zwilling
Copy link
Author

From looking at the code, I am wondering if the Atoms allocated by PL_new_atom = _lib.PL_new_atom need to be freed again.

@yuce yuce added this to the v0.3.3 milestone Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants