You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The inotify observer has a memory leak, specifically around moved files. I think I've tracked it down to this _moved_from_events dictionary in inotify_c.py. There is a clear_move_records() function that never appears to be called by anything.
See code below for a simple repro. Run as-is and it will gradually use up more and more memory. If you uncomment the 'clear_move_records' line, it will not.
Unfortunately I'm not familiar enough with the code to know when would be an appropriate time to actually call this function, or if it should be getting cleaned up in some other way.
fromwatchdog.eventsimportPatternMatchingEventHandlerfromwatchdog.observersimportObserverfromthreadingimportThreadfrompathlibimportPathdefthread_main():
filename="file1"Path(filename).write_text("dummy")
foriinrange(1000000):
new_filename=f"{'a'*100}.{i}"Path(filename).rename(new_filename)
filename=new_filenameobserver=Observer()
classTestHandler(PatternMatchingEventHandler):
defon_moved(self, event):
# Uncomment this line to 'fix' the memory leak# list(observer.emitters)[0]._inotify._inotify.clear_move_records()print("MOVED")
defmain():
th=Thread(target=thread_main)
th.start()
handler=TestHandler(patterns=["*"])
observer.schedule(handler, ".")
observer.start()
th.join()
if__name__=="__main__":
main()
The text was updated successfully, but these errors were encountered:
The inotify observer has a memory leak, specifically around moved files. I think I've tracked it down to this
_moved_from_events
dictionary in inotify_c.py. There is aclear_move_records()
function that never appears to be called by anything.See code below for a simple repro. Run as-is and it will gradually use up more and more memory. If you uncomment the 'clear_move_records' line, it will not.
Unfortunately I'm not familiar enough with the code to know when would be an appropriate time to actually call this function, or if it should be getting cleaned up in some other way.
The text was updated successfully, but these errors were encountered: