Answer the question
In order to leave comments, you need to log in
Why is memory not freed in python?
Hello.
On python 3, there is the following function (only part of it, there is no particular point in giving the second part so as not to confuse anyone):
def checkNewProjects(link, last_project, timeout, config, session):
"""Function for check new projects and for restarting timer event"""
time.sleep(timeout)#Wait pause before start parsing
print("Checking projects")
if last_project == "": #It is first launch of function. Need only find last project.
request = session.get(link).text
html = BeautifulSoup(request, "html.parser")
last_project = html.select(".projects .proj")[0].select("h2 a")[0]["href"] #finding link of last project for save
del request, html
checkNewProjects(link, last_project, timeout, config, session)
return
Answer the question
In order to leave comments, you need to log in
After I rewrote the recursive function call to call the same function in an infinite loop, the memory stopped escaping in such volumes =)
Thanks for the help, Pavel Denisov
What if we try to move the memory-consuming code into a separate function?
def memoryEater():
"""eats memory"""
request = session.get(link).text
html = BeautifulSoup(request, "html.parser")
return html.select(".projects .proj")[0].select("h2 a")[0]["href"] #finding link of last project for save
def checkNewProjects(link, last_project, timeout, config, session):
"""Function for check new projects and for restarting timer event"""
time.sleep(timeout)#Wait pause before start parsing
print("Checking projects")
if last_project == "": #It is first launch of function. Need only find last project.
last_project = memoryEater()
checkNewProjects(link, last_project, timeout, config, session)
return
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question