I
I
Ivan21212015-04-14 11:18:22
Python
Ivan2121, 2015-04-14 11:18:22

How to reduce memory consumption when running python scripts?

Hello! I wrote a parser in python, 6-7 scripts work daily at the same time. In this case, several pythonw.exe processes hang in the task manager, 3-4 of which immediately after launch take 1.5 GB of RAM each. But at the same time, I noticed that after a few hours, only 1 or 2 processes consumed 1.5 GB each, and the rest were 10 times less. How to make it so that during startup and further work the consumed memory of pythons is not large?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
throughtheether, 2015-04-14
@throughtheether

How to make it so that during startup and further work the consumed memory of pythons is not large?
Without seeing the code, it's hard to judge anything, but I can give advice. When parsing, when you extract the characteristics of a "unit" of data (an online store product or a tweet on Twitter), instead of passing a list containing many "units" of data to another function, pass them one by one using yield.

V
Vadim Shandrinov, 2015-04-14
@suguby

use not a DOM parser - it puts everything in memory, but a SAX parser, for example lxml.de

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question