I am new to python and have a big memory problem. my script runs 24/7 and every day it allocates about 1 GB of my memory. I could narrow it down to this function:
Code:
import gc
from pympler import muppy
from pympler import summary
from pympler import tracker
v_list = [{
'url_base' : 'http://www.immoscout24.de',
'url_before_page' : '/Suche/S-T/P-',
'url_after_page' : '/Wohnung-Kauf/Hamburg/Hamburg/-/-/50,00-/EURO--500000,00?pagerReporting=true',}]
def get_url(v, page_num):
return v['url_base'] + v['url_before_page'] + str(page_num) + v['url_after_page']
while True:
gc.enable()
for v_idx,v in enumerate(v_list):
all_objects = muppy.get_objects()
sum1 = summary.summarize(all_objects)
summary.print_(sum1)
url = get_url(v, 1)
all_objects = muppy.get_objects()
sum1 = summary.summarize(all_objects)
summary.print_(sum1)
gc.collect()
Output:
======================== | =========== | ============
list | 26154 | 10.90 MB
str | 31202 | 1.90 MB
dict | 507 | 785.88 KB
expelially the list attribute is getting bigger and bigger, each cycle is about 600kb, and I have no idea why. in my opinion, I do not store anything here, and the url variable should be rewritten every time. therefore basically should be memory consumption in general.
What am I missing here? :-)
source
share