Hey guys, i'm currently building a bot that refreshes a webpage every 30 seconds, but as i'm running it off my own machine I don't really want it opening and closing a browser every minute so I opted to use driver.refresh() over driver.quit(). The issue i'm having is that after every refresh the memory usage on the page increases by 100~ mb and after about an hour it crashes due to lack of memory. Does anyone have a solution they can think of to solve this. Below is some of the code used for reference and a snapshot of the memory usage after a minute:
Tried:
switching browser
running in a separate thread
setting max script run time to 10s
reset = True
def check_site():
global reset
page_source = driver.page_source
try:
element_detected = WebDriverWait(driver, 3).until(
EC.presence_of_element_located((By.XPATH, ""))
)
send_discord_notification(f"@skyrift3r Message")
reset = False
return reset
except TimeoutException as e:
print("TimeoutException: Element not found within the specified time.")
time.sleep(3)
driver.refresh()
return reset
except Exception as e:
print("Error:", str(e))
time.sleep(3)
driver.refresh()
return reset
while reset:
check_site()```