scan data from es may have memory leak
See original GitHub issueI found memory leak when I’ve got data from elasticsearch.
`import gc import time import psutil import elasticsearch from elasticsearch import Elasticsearch, helpers
print('elasticsearch version: ', elasticsearch.version) print(‘start mem: {:.4f} gb’.format(psutil.virtual_memory().used / 1024 / 1024 / 1024)) es = Elasticsearch(hosts=‘192.168.83.222:9200’) query = {‘query’:{‘term’:{‘ORG_NO’:‘3140201’}}} repl = helpers.scan(client=es, query=query, index=‘hb_mp_info-3140201-2020.10.10’, size=10000) l = [ele for ele in repl] del l gc.collect() time.sleep(5) print(‘end mem: {:.4f} gb’.format(psutil.virtual_memory().used / 1024 / 1024 / 1024))`
Run the above code, we can see: start mem: 6.3883 gb end mem: 7.2465 gb I feel that 0.86 gb memory ware leaking.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
shouldn’t this be moved to elastic/elasticsearch-py ?
Having the same issue while using async_scan helper. any updates?