Skip to content

Commit

Permalink
try to fix possible memory leak in libxc (pyscf#189)
Browse files Browse the repository at this point in the history
* try to fix possible memory leak in libxc

* unchange example

* unchange example

* Update libxc.py
  • Loading branch information
wxj6000 authored Jul 28, 2024
1 parent cb3bad4 commit 8fdfaa8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions gpu4pyscf/dft/libxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class _xcfun(ctypes.Structure):
_libxc.xc_func_init.argtypes = (_xc_func_p, ctypes.c_int, ctypes.c_int)
_libxc.xc_func_end.argtypes = (_xc_func_p, )
_libxc.xc_func_free.argtypes = (_xc_func_p, )
_libxc.xc_func_alloc()

class XCfun:
def __init__(self, xc, spin):
Expand All @@ -100,9 +99,8 @@ def __init__(self, xc, spin):
def __del__(self):
if self.xc_func is None:
return
# TODO: deallocate xc func
#_libxc.xc_func_end(self.xc_func)
#_libxc.xc_func_free(self.xc_func)
_libxc.xc_func_end(self.xc_func)
_libxc.xc_func_free(self.xc_func)

def needs_laplacian(self):
return dft.libxc.needs_laplacian(self.func_id)
Expand Down

0 comments on commit 8fdfaa8

Please sign in to comment.