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
I am trying to get top window in MacOS after every click or keyboard activity. But the for loop to go through all windows for finding the active window has memory issues in Quartz.
I made the following test. If you comment the for loop part, memory leak stops.
Any fixes?
from memory_profiler import profile
import sys, time, Quartz
import pygetwindow as gw
def _get_active_window():
windows = Quartz.CGWindowListCopyWindowInfo(Quartz.kCGWindowListExcludeDesktopElements | Quartz.kCGWindowListOptionOnScreenOnly, Quartz.kCGNullWindowID)
for win in windows:
if win['kCGWindowLayer'] == 0:
return '%s %s' % (win[Quartz.kCGWindowOwnerName], win.get(Quartz.kCGWindowName, ''))
@profile
def main(n):
for i in range(n):
_get_active_window()
for i in range(100):
main(20*i)
The text was updated successfully, but these errors were encountered:
I am trying to get top window in MacOS after every click or keyboard activity. But the for loop to go through all windows for finding the active window has memory issues in Quartz.
I made the following test. If you comment the for loop part, memory leak stops.
Any fixes?
The text was updated successfully, but these errors were encountered: